Annotation Interface IdClass


@Target(TYPE) @Retention(RUNTIME) public @interface IdClass
Specifies a composite primary key type whose fields or properties map to the identifier fields or properties of the annotated entity class.

The specified primary key type must:

  • be a non-abstract regular Java class, or a Java record type,
  • have a public or protected constructor with no parameters, unless it is a record type, and
  • implement Annotation.equals(java.lang.Object) and Annotation.hashCode(), defining value equality consistently with equality of the mapped primary key of the database table.

The primary key fields of the entity must be annotated Id, and the specified primary key type must have fields or properties with matching names and types. The mapping of fields or properties of the entity to fields or properties of the primary key class is implicit. The primary key type does not itself need to be annotated.

Example:

Since:
1.0
See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The primary key class, which must declare fields or properties with names and types that match the Id fields and properties of the annotated entity class.
  • Element Details

    • value

      Class<?> value
      The primary key class, which must declare fields or properties with names and types that match the Id fields and properties of the annotated entity class.