@idclass vs @embedable

1. @Idclass


@Entity @IdClass(ProjectId.class)
public class Project {
    @Id int departmentId;
    @Id long projectId;
     :
}


Class ProjectId {
    int departmentId;
    long projectId;
}



2.@embedable


@Entity
public class Project {
    @EmbeddedId ProjectId id;
     :
}


@Embeddable
Class ProjectId {
    int departmentId;
    long projectId;
}





Ref: https://www.objectdb.com/java/jpa/entity/id









Comments

Popular posts from this blog

Fixing the DeepSpeed Import Error While Fine-Tuning the Qwen Model

Amazon Linux 2023 - User data configuration for launch templates to connect to the EKS cluster

How to create ISM policy and rotate logs in opensearch