Annotation Type UniqueKeys
-
@Target(TYPE) @Retention(RUNTIME) public @interface UniqueKeysUniqueKeys annotation describe one or more unique keys of an entity type. Different from JPA UniqueConstraint for entity tables, UniqueKeys can annotate an entity type or its superclass, and UniqueKeys annotation in a subclass will override that of its superclass. For example,
UniqueKeys will be validated when creating and changing entities before committed to persistence, and user friendly message will be displayed if any unique constraint is violated.@UniqueKeys({ @UniqueKey(properties={"id"}), @UniqueKey(properties={"name", "phone"}) }) @Entity(name="Employee") public class Employee extends Person { } @UniqueKeys({ @UniqueKey(properties={"id"}), @UniqueKey(properties={"name", "address"}) }) @MappedSuperclass abstract public class Person { }Note that UniqueKeys annotation is for validation only and will not generate table unique constraints in DDL.
- Since:
- 4.2
-
-
Element Detail
-
value
UniqueKey[] value
a list of UniqueKey annotations
-
-