Hibernate Tips: Easiest way to manage bi-directional associations
|

Hibernate Tips: Easiest way to manage bi-directional associations

Hibernate Tips is a series of posts in which I describe a quick and easy solution for common Hibernate questions. If you have a question for a future Hibernate Tip, please leave a comment below. Question: Updating both ends of a bidirectional association is an error-prone task. What’s the best way to implement it in…

Hibernate Tips: How to avoid Hibernate’s MultipleBagFetchException

Hibernate Tips: How to avoid Hibernate’s MultipleBagFetchException

Hibernate Tips is a series of posts in which I describe a quick and easy solution for common Hibernate questions. If you have a question for a future Hibernate Tip, please leave a comment below. Question: You explained that I should use a JOIN FETCH clause to initialize all associations of my entity that I…

Composition vs. Inheritance with JPA and Hibernate
|

Composition vs. Inheritance with JPA and Hibernate

Like all object-oriented programing languages, Java supports the fundamental concepts of inheritance and composition. There is an important difference between both concepts. Inheritance enables you to model an is-a association between two classes by extending a superclass. Composition models a has-a association by referencing another class in an instance variable. You can use both concepts…