Annotation Interface TargetIdProperty


@Retention(CLASS) @Target({FIELD,TYPE}) public @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
    Modifier and Type
    Required Element
    Description
    Name used in the database.
  • Element Details

    • value

      String value
      Name used in the database.