ManyToOne JPA and Hibernate association best practices

Introduction In this article, I’m going to show you what is the best way to map a ManyToOne association when using JPA and Hibernate. Since the @ManyToOne association is the most common relationship, knowing how to map it properly will have a significant impact on application performance.

How to map a @ManyToOne association using a non-Primary Key column with JPA and Hibernate

Introduction While answering questions on the Hibernate forum, I stumbled on the following question about using the @ManyToOne annotation when the Foreign Key column on the client side references a non-Primary Key column on the parent side. In this article, you are going to see how to use the @JoinColumn annotation in order to accommodate non-Primary Key many-to-one associations.

The best way to map a @OneToMany relationship with JPA and Hibernate

Introduction While adding a @OneToMany relationship is very easy with JPA and Hibernate, knowing the right way to map such an association so that it generates very efficient SQL statements is definitely not a trivial thing to do. In a relational database system, a one-to-many association links two tables based on a Foreign Key column so that the child table record references the Primary Key of the parent table row. As straightforward as it might be in a relational database, when it comes to JPA, the one-to-many database association can be represented… Read More