How-to articles, tricks, and solutions about HIBERNATE

could not extract ResultSet in hibernate

If you are trying to execute a query using Hibernate and are getting an error saying "could not extract ResultSet," it could be due to a few different issues:

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).

Hibernate throws MultipleBagFetchException - cannot simultaneously fetch multiple bags

If you are using Hibernate and you see the error "MultipleBagFetchException: cannot simultaneously fetch multiple bags", it means that you are trying to fetch multiple collections of an entity using a single Hibernate query.

How can I log SQL statements in Spring Boot?

To log SQL statements in Spring Boot, you can configure the logging level of the org.hibernate.SQL logger to DEBUG or TRACE.

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 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.

How to solve the “failed to lazily initialize a collection of role” Hibernate exception

The "failed to lazily initialize a collection of role" exception in Hibernate is thrown when you try to access an uninitialized collection from a Hibernate entity when the entity is in a detached state.

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 are the possible values of the Hibernate configuration and what do they do

The configuration property in Hibernate determines the mode in which Hibernate should operate when it comes to generating the database schema. The possible values for this property are:

What's the difference between JPA and Hibernate?

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