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…

Hibernate Tips: How to Share the Primary Key in a One-to-One Association
|

Hibernate Tips: How to Share the Primary Key in a One-to-One Association

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: I need to map a one-to-one association in which the primary key value of one entity is also used…

How to Choose the Most Efficient Data Type for To-Many Associations – Bag vs. List vs. Set

How to Choose the Most Efficient Data Type for To-Many Associations – Bag vs. List vs. Set

Which data type should you use to map a to-many association with Hibernate? Is it better to use a Set or a List? That’s a very common question, and most developers are surprised when they look at the documentation and find out that these are not the only options. You can also use a Bag…

Getting Started With Hibernate
| |

Getting Started With Hibernate

Hibernate is a very popular implementation of the Java Persistence API (JPA) standard. It acts as an additional layer on top of JDBC and enables you to implement a database-independent persistence layer. Hibernate provides an object-relational mapping implementation that maps your database records to Java objects and generates the required SQL statements to replicate all operations to the database. Let’s…

Hibernate Tips: How to model an association that doesn’t reference primary key columns
|

Hibernate Tips: How to model an association that doesn’t reference primary key columns

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: I have to map a legacy table model with Hibernate. It contains a many-to-one association that uses a non-primary…