Skip to content

Package: FieldResult

FieldResult

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 java.lang.annotation.Retention;
18: import java.lang.annotation.RetentionPolicy;
19: import java.lang.annotation.Target;
20:
21: /**
22: * Used in conjunction with the {@link EntityResult} annotation to map columns specified in the SELECT list of a SPARQL
23: * query to the properties or fields of an entity class.
24: *
25: * Note that if variable is not bound in result row, the field is skipped (its value is not set).
26: * <p>
27: * Example:
28: * <pre>
29: * <code>
30: * Query q = em.createNativeQuery(
31: * "SELECT ?x, ?quantity, ?item, ?label, ?description "+
32: * "WHERE {
33: * ?x a <http://onto.fel.cvut.cz/ontologies/jopa/Order> ;
34: * <http://onto.fel.cvut.cz/ontologies/ufo/has_part> ?item .
35: * ?item a <http://onto.fel.cvut.cz/ontologies/jopa/Order> ;
36: * rdfs:label ?label;
37: * rdfs:comment ?description .
38: * }", "OrderItemResults");
39: *
40: * {@literal @}SparqlResultSetMapping(name="OrderItemResults",
41: * entities={
42: * {@literal @}EntityResult(entityClass=cz.cvut.kbss.jopa.Order.class, fields = {
43: * {@literal @}FieldResult(name="uri", variable="x")
44: * }),
45: * {@literal @}EntityResult(entityClass=cz.cvut.kbss.jopa.Item.class)
46: * })
47: * </code>
48: * </pre>
49: *
50: * @see EntityResult
51: * @see SparqlResultSetMapping
52: */
53: @Target({})
54: @Retention(RetentionPolicy.RUNTIME)
55: public @interface FieldResult {
56:
57: /**
58: * Name of the persistent field or property of the class.
59: */
60: String name();
61:
62: /**
63: * Name of the variable in the SELECT clause.
64: */
65: String variable();
66: }