Skip to content

Package: SparqlResultSetMapping

SparqlResultSetMapping

Coverage

1: /**
2: * Copyright (C) 2022 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.jopa.model.annotations;
16:
17: import cz.cvut.kbss.jopa.model.query.Query;
18:
19: import java.lang.annotation.ElementType;
20: import java.lang.annotation.Retention;
21: import java.lang.annotation.RetentionPolicy;
22: import java.lang.annotation.Target;
23:
24: /**
25: * Specifies the mapping of the result of a native SPARQL query.
26: * <p>
27: * Example:
28: * <pre>
29: * <code>
30: * Query q = em.createNativeQuery("SELECT ?uri ?label ?comment WHERE {" +
31: * "?uri a <http://onto.fel.cvut.cz/ontologies/jopa/Example> ;" +
32: * "rdfs:label ?label ;" +
33: * "rdfs:comment ?comment ." +
34: * "}", "ExampleResults");
35: * </code>
36: * </pre>
37: *
38: * <pre>
39: * <code>
40: * {@literal @}SparqlResultSetMapping(name="ExampleResults",
41: * classes={
42: * {@literal @}ConstructorResult(targetClass=cz.cvut.kbss.jopa.Example, variables={
43: * {@literal @}VariableResult(name="uri"),
44: * {@literal @}VariableResult(name="label"),
45: * {@literal @}VariableResult(name="comment")
46: * }
47: * }
48: * )
49: * </code>
50: * </pre>
51: *
52: * @see Query
53: * @see NamedNativeQuery
54: */
55: @Target(value = ElementType.TYPE)
56: @Retention(value = RetentionPolicy.RUNTIME)
57: public @interface SparqlResultSetMapping {
58:
59: /**
60: * The name given to the result set mapping and used to refer to it in the methods of the {@link Query} API.
61: */
62: String name();
63:
64: /**
65: * Specifies the result set mapping to constructors.
66: */
67: ConstructorResult[] classes() default {};
68:
69: /**
70: * Specifies the result set mapping to entities.
71: */
72: EntityResult[] entities() default {};
73:
74: /**
75: * Specifies the result set mapping to scalar values.
76: */
77: VariableResult[] variables() default {};
78: }