Skip to contentPackage: FieldResult
FieldResult
Coverage
1: /*
2: * JOPA
3: * Copyright (C) 2023 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jopa.model.annotations;
19:
20: import java.lang.annotation.Retention;
21: import java.lang.annotation.RetentionPolicy;
22: import java.lang.annotation.Target;
23:
24: /**
25: * Used in conjunction with the {@link EntityResult} annotation to map columns specified in the SELECT list of a SPARQL
26: * query to the properties or fields of an entity class.
27: *
28: * Note that if variable is not bound in result row, the field is skipped (its value is not set).
29: * <p>
30: * Example:
31: * <pre>
32: * <code>
33: * Query q = em.createNativeQuery(
34: * "SELECT ?x, ?quantity, ?item, ?label, ?description "+
35: * "WHERE {
36: * ?x a <http://onto.fel.cvut.cz/ontologies/jopa/Order> ;
37: * <http://onto.fel.cvut.cz/ontologies/ufo/has_part> ?item .
38: * ?item a <http://onto.fel.cvut.cz/ontologies/jopa/Order> ;
39: * rdfs:label ?label;
40: * rdfs:comment ?description .
41: * }", "OrderItemResults");
42: *
43: * {@literal @}SparqlResultSetMapping(name="OrderItemResults",
44: * entities={
45: * {@literal @}EntityResult(entityClass=cz.cvut.kbss.jopa.Order.class, fields = {
46: * {@literal @}FieldResult(name="uri", variable="x")
47: * }),
48: * {@literal @}EntityResult(entityClass=cz.cvut.kbss.jopa.Item.class)
49: * })
50: * </code>
51: * </pre>
52: *
53: * @see EntityResult
54: * @see SparqlResultSetMapping
55: */
56: @Target({})
57: @Retention(RetentionPolicy.RUNTIME)
58: public @interface FieldResult {
59:
60: /**
61: * Name of the persistent field or property of the class.
62: */
63: String name();
64:
65: /**
66: * Name of the variable in the SELECT clause.
67: */
68: String variable();
69: }