Category Archives: Hibernate

Difference between save vs persist in Hibernate

In this post, We will try to understand the difference between save vs persist in Hibernate. save(obj) persist(ob) It returns generated id and the return type is serializable It does not return anything. It’s a void return type. It can save object within boundaries and outside boundaries It can only save object within the transaction… Read More »

Difference between get() and load() methods in Hibernate

In this post, We will learn the difference between get() and load() methods in Hibernate.  When we call the load() method hibernate creates a proxy object and returns the proxy object, but in the case of get() method, there is no concept called proxy it directly hits/calls the database. The load() method loads an object… Read More »

What are the important paradigms for Developing the Clean Object-Oriented Code?

In this blog post we will discuss about What are the important paradigms for Developing the Clean Object-Oriented Code? We should always keep in mind below key points when you write code in your application: We should use an Interface (or the Super Type) not the implementation. Classes Interacting each other should be loosely coupled among… Read More »

Hibernate hbm2ddl property

In our previous post Why to use hibernate dialect? we understood all the concept related to hibernate dialect property In this post we will talk about hibernate hbm2ddl property in detail using an example. Hibernate hbm2ddl property you can configure in your hibernate.cfg.xml as below

  The possible values for hibernate.hbm2ddl.auto are: create validate update create-drop Create If the… Read More »

Why to use hibernate dialect?

In this post we will discuss about hibernate dialect property in detail. This property tells Hibernate to generate the appropriate SQL statements for the chosen database. For Example for MySQL database we set hibernate dialect as below in hibernate config file in our example Hibernate CRUD(Create,Read,Update and Delete) example.

If you expand hibernate-core jar in your favorite IDE… Read More »

Understanding hibernate Configuration File

In previous post Dirty checking in hibernate example we learnt what dirty checking concept in hibernate. In this post we will understand most of the important properties available in hibernate.cfg.xml file Let’s take hibernate configuration file from our previous example where we have learnt about Dirty checking in hibernate hibernate.cfg.xml

First line in the above XML… Read More »

Dirty checking in hibernate example

In previous post Hibernate CRUD example in hibernate you learnt how to perform Create,Read,Update and Delete operation with database.In this post I will demonstrate about Dirty checking in hibernate example step by step using below project. Technologies and tools used for this application are – Hibernate 5.2.11.Final Eclipse Mars.2 (4.5.0) Maven 3.5.0 JavaSE 1.8 MySQL 5.5.57 Project Structure Review… Read More »

Hibernate CRUD example

In previous post Save and persist an entity example in hibernate you learnt how to save an entity object in database. This post demonstrates how to perform CRUD(Create,Read,Update and Delete) operation is hibernate step by step. Technologies and tools used for this application are – Hibernate 5.2.11.Final Eclipse Mars.2 (4.5.0) Maven 3.5.0 JavaSE 1.8 MySQL 5.5.57 Project… Read More »

Save and persist an entity example in hibernate

In Hibernate framework, an entity object can be persisted or saved into database using the following methods – save() → This method is used to save an entity object into database and returns a generated identifier or primary key. This method throws an exception if an entity already exists in the database. persist() → This method is… Read More »

what are the benefits of using hibernate?

This Post talks about what are the benefits of using hibernate? Below are the key benefits of using hibernate framework: Hibernate is an Object/Relational Mapping solution for Java programming language. The term Object Relational Mapping refers to the process of mapping data from java object model representation to a relational data base representation (and vice versa). Hibernate framework… Read More »