File tree Expand file tree Collapse file tree
objectbox-java-api/src/main/java/io/objectbox/annotation Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222import java .lang .annotation .Target ;
2323
2424/**
25- * Defines the property serving as the target ID of a ToOne.
26- * This allows exposing an explicit property, which may be convenient for other parsers/serializers (e.g. JSON).
25+ * For a ToOne, changes the name of the property to store the target object ID in from the default name:
26+ * <p>
27+ * <pre>{@code
28+ * @Entity
29+ * public class Order {
30+ * @TargetIdProperty("customerRenamedTargetId")
31+ * ToOne<Customer> customer;
32+ * long customerRenamedTargetId;
33+ * }
34+ * }</pre>
35+ * <p>
36+ * By default, a target ID property named like the ToOne property with the suffix "Id" is created implicitly (so without
37+ * defining it in the @Entity class). Using the example above, without the annotation a "virtual" property named
38+ * {@code long customerId} would be created.
39+ * <p>
40+ * Exposing the target ID as an actual field (so not necessarily renamed using this annotation) can be useful for other
41+ * parsers or serializers, like for JSON.
42+ * <p>
43+ * See the <a href="https://docs.objectbox.io/relations">relations documentation</a> for details.
2744 */
2845@ Retention (RetentionPolicy .CLASS )
2946@ Target ({ElementType .FIELD , ElementType .TYPE })
You can’t perform that action at this time.
0 commit comments