Difference between save(), saveOrUpdate() and persist() in Hibernate Session

The Session interface in Hibernate provides a couple of methods to move an object from a new or transient state to a persistent state like save(), saveOrUpdate(), and persist() is used to store an object into the database, but there are some significant differences between them. The Session.save() method does an INSERT to store the object into the database and it also returns the identifier generated by the database. On the other hand, saveOrUpdate() can be used to reattach a detached object in Hibernate Session i.e. it can do INSERT or UPDATE depending upon whether an object exists in the database or not. 

How to fix access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set? [Solved]

Hello and welcome to the blog post. Today we are going to take a look at another frequently encountered issue while working with Spring Boot and Hibernate. The error "Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set" usually comes when Hibernate is unable to determine the appropriate database dialect to use. This error can be fixed by setting the hibernate.dialect property in your Hibernate configuration file. In this post, we'll look at a fix for the issue where a Spring Boot applications' "hibernate.dialect" setting prevents access to dialectresolutioninfo from being null., But before that let's take a look at the Exception itself.

Differences Between JPA, Hibernate, and MyBatis

Hello guys Are you tired of using plain old SQL to access your database? Are you looking for a better way to manage your database interactions in Java? Well, you're in luck because JPA, Hibernate, and MyBatis are here to save the day! If you're a Java developer, you've likely come across the terms JPA, Hibernate, and MyBatis when working with databases. While they all deal with object-relational mapping (ORM), they have their own distinct approaches and features. Understanding the differences between them can help you make informed decisions when choosing which one to use for your projects.

Difference between Hibernate, JPA, MyBatis

Hello guys, if you are wondering what is difference between Hibernate, JPA, and MyBatis in Java world and when to use them then you have come to the right place. Earlier, I have shared Hibernate Courses, books, and Interview Questions and in this article, I will answer this popular Hibernate question from Java developer's perspective.  This article aims to give a brief overview of Hibernate, JPA, and MyBatis. Moving ahead highlights the difference between them. It also put light on which underlying technologies they use. Lastly, it provides verdicts on when to use which one among these. But, before we start with the difference between JPA, Hibernate, and MyBatis. It is important to have an understanding of these technologies first.

Top 20 Hibernate Interview Questions with Answers for Java Programmers

Hibernate is one of the most popular persistent frameworks in the Java world. Hibernate offers an object to relational (ORM) solution which frees Java developers from writing tedious, hard to read, and cluttered JDBC code converting SQL columns into Object properties. Apart from freeing Java developers from writing JDBC and database interaction code, Hibernate also offers the out-of-box solution on caching, proxying, and lazy loading which drastically improves the performance of your Java Web application. 

Difference between first level and second level cache in Hibernate

The main difference between the first level and second level cache in Hibernate is that the first level is maintained at the Session level and accessible only to the Session, while the second level cache is maintained at the SessionFactory level and available to all Sessions. This means, you can use the first-level cache to store local data, i.e. the data which is needed by the Session, and you can use the second-level cache to store global data, i.e. something which can be shared across sessions. This is also one of the frequently asked Hibernate Interview questions and accessible in both telephonic rounds as well as on the face-to-face interviews, in both fresher and experienced level interviews.

10 points about JPA Entity Class for Hibernate Java developers.

JPA Entity class is in core of JPA specification and its one of the most important thing a Java developer should know, while working with JPA implementations like Hibernate. Many Java programmers either not aware of these rules and best practices or doesn't pay enough attention while creating JPA entity class to end up with same mistakes e.g. equals and hashcode not working, issues with access type etc. This motivates me to hund down and write these rules


The entity class must have a no-arg constructor. It may have other constructors as well. The no-arg constructor must be public or protected.
The entity class must a be top-level class. An enum or interface must not not be designated as an entity.
The entity class must not be final. No methods or persistent instance variables of the entity class may be final.
If an entity instance is to be passed by value as a detached object (e.g., through a remote interface), the entity class must implement the Serializable interface.
Both abstract and concrete classes can be entities. Entities may extend non-entity classes as well as entity classes, and non-entity classes may extend entity classes.

http://stackoverflow.com/questions/6033905/create-the-perfect-jpa-entity

Further Learning
Introduction To Hibernate
Spring with JPA and Hibernate
Introduction to Spring MVC
Java Web Fundamentals by Kevin Jones