How-to articles, tricks, and solutions about ORM

Difference between FetchType LAZY and EAGER in Java Persistence API?

In the Java Persistence API (JPA), the FetchType enum is used to specify the strategy for fetching data from the database.

Hibernate show real SQL

To show the real SQL generated by Hibernate, you can enable the show_sql property in the Hibernate configuration file (hibernate.cfg.xml).

How to fix org.hibernate.LazyInitializationException - could not initialize proxy - no Session

The LazyInitializationException in Hibernate is thrown when an object that has been loaded with a "lazy" fetch type is accessed outside of a valid session.

How to Make Laravel Eloquent "IN" Query?

You can use the whereIn method on a query builder instance to create an "IN" clause for a given column and values.

How to print a query string with parameter values when using Hibernate

To print a Hibernate query string with parameter values, you can use the toString() method of the Query interface.

JPA JoinColumn vs mappedBy

In a JPA entity mapping, the @JoinColumn annotation is used to specify the foreign key column for a many-to-one or one-to-one relationship.

What's the difference between JPA and Hibernate?

Java Persistence API (JPA) is a specification for object-relational mapping (ORM) in Java.