Which annotation should I use: @IdClass or @EmbeddedId

I consider that @EmbeddedId is probably more verbose because with @IdClass you cannot access the entire primary key object using any field access operator. Using the @EmbeddedId you can do like this: @Embeddable class EmployeeId { name, dataOfBirth } @Entity class Employee { @EmbeddedId EmployeeId employeeId; … } This gives a clear notion of the … Read more

Difference between FetchType LAZY and EAGER in Java Persistence API?

Sometimes you have two entities and there’s a relationship between them. For example, you might have an entity called University and another entity called Student and a University might have many Students: The University entity might have some basic properties such as id, name, address, etc. as well as a collection property called students that … Read more