Annotation Interface ConstructorResult


@Target({}) @Retention(RUNTIME) public @interface ConstructorResult
Used in conjunction with the SparqlResultSetMapping annotation to map the SELECT clause of a SPARQL query to a constructor.

Applies a constructor for the target class, passing in as arguments values from the specified variables. All variables corresponding to arguments of the intended constructor must be specified using the variables element of the ConstructorResult annotation in the same order as that of the argument list of the constructor. Any entities returned as constructor results will be in either the new or detached state, depending on whether a primary key is retrieved for the constructed object.

Example:

     
 Query q = em.createNativeQuery("SELECT ?uri ?label ?comment WHERE {" +
             "?uri a <http://onto.fel.cvut.cz/ontologies/jopa/Example> ;" +
                  "rdfs:label ?label ;" +
                  "rdfs:comment ?comment ." +
         "}", "ExampleResults");
     
 
     
 @SparqlResultSetMapping(name="ExampleResults",
          classes={
              @ConstructorResult(targetClass=cz.cvut.kbss.jopa.Example, variables={
                  @VariableResult(name="uri"),
                  @VariableResult(name="label"),
                  @VariableResult(name="comment")
              }
          }
      )
     
 
See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    (Required) The class whose constructor is to be invoked.
    (Required) The mapping of variables in the SELECT list to the arguments of the intended constructor, in order.
  • Element Details

    • targetClass

      Class<?> targetClass
      (Required) The class whose constructor is to be invoked.
    • variables

      VariableResult[] variables
      (Required) The mapping of variables in the SELECT list to the arguments of the intended constructor, in order.