Top Description Methods
jakarta.persistence

public @Interface IdClass

extends Annotation
Annotations
@Target:TYPE
@Retention:RUNTIME
Imports
java.lang.annotation.Target, .Retention

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:

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) {}
@IdClass(EmployeePK.class)
@Entity
public class Employee {
    @Id
    String empName;
    @Id
    Date birthDay;
    ...
}

public record EmployeePK(String empName, Date birthDay) {}
Since
1.0
See Also
EmbeddedId

Method Summary

Modifier and TypeMethod and Description
public 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.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

valueback to summary
public 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.