Package io.objectbox.annotation
Annotation Interface TargetIdProperty
For a ToOne, changes the name of its associated target ID (or "relation") property.
@Entity
public class Order {
// Change from default "customerId" to "customerRef"
@TargetIdProperty("customerRef")
ToOne<Customer> customer;
// Optional: expose target ID property (using changed name)
long customerRef;
}
A target ID property is implicitly created (so without defining it in the @Entity class) for each
ToOne and stores the ID of the referenced target object. By default, it's named like the ToOne field plus the suffix
"Id" (for example customerId).
Like in the example above, it's still possible to expose the target ID property as an actual field (useful for other parsers or serializers, like for JSON). But make sure to use the changed name for the field.
See the relations documentation for details.
-
Required Element Summary
Required Elements
-
Element Details
-
value
String valueName used in the database.
-