The specified primary key type must:
abstract regular Java class, or a
Java record type,
public or protected constructor
with no parameters, unless it is a record type, and
equals and 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:
@IdClass(EmployeePK.class)
@Entity
public class Employee {
@Id
String empName;
@Id
Date birthDay;
...
}
public record EmployeePK(String empName, Date birthDay) {}
EmbeddedId
| Modifier and Type | Method and Description |
|---|---|
| public Class |
| value | back to summary |
|---|---|
| public Class The primary key class, which must declare fields or
properties with names and types that match the
| |