save(), saveOrUpdate(), persist() in Hibernate

Introduction In this tutorial we will discuss about the differences among save(), saveOrUpdate() and persist() method in leading ORM(Object Relational Mapping) tool Hibernate framework. The key thing is all these methods are used to store object(s) into database and they also make transient object(s) into persistent. Hibernate framework’s Session class provides a few ways to save objects by methods save(), saveOrUpdate() and persist() based on requirements for persisting objects into database.

Continue

How to create Java based Hibernate Configurations

Introduction In this tutorial we will discuss how to create Java based Hibernate configurations. In Java based configuration we don’t need to create any XML or properties file for putting Hibernate configuration. We will put Hibernate configuration as well SessionFactory using Java based configuration. To make everything clarified we will create both XML and Java based configuration so that it would be easy to understand.

Continue

Spring Boot MVC and Hibernate CRUD Example

Introduction In this tutorial we will create an example on Spring Boot MVC and Hibernate CRUD. CRUD is an acronym that means Create, Read, Update and Delete operations. In my other tutorial I had also created Spring Boot MVC and JDBC CRUD Example. We will build the tutorial example using both maven and gradle build tools. We will create the annotation based hibernate configuration with Spring Boot framework. We are going to use MySQL database as a persistence storage for our application.

Continue

Form Validation in Spring Boot Web Application

Introduction In this example we will see an example on how to validate form in web application using Spring Boot framework. We will use Thymeleaf as a template for UI (user interface) or front-end. We will perform almost all kinds of validations available through Hibernate validator framework. This example just validates the input values and once validated successfully it just sends a success response to the end user or client. It does not perform any business on the server side. We will build our application both on gradle and maven…

Continue

What is the use of @Temporal annotation in JPA

Here you will know what is the use of @Temporal annotation in JPA. @Temporal is a JPA annotation and generally specified only for persistent fields or properties of type java.util.Date and java.util.Calendar. Generally you use @Temporal annotation on the date or calendar field in entity classes during table and Java class mapping where Hibernate is used as an ORM (Object Relational Mapping) framework. You won’t be able to apply @Temporal annotation on Java 8 date time API. If you try to use @Temporal annotation on Java 8 date time API then…

Continue

How to connect multiple database servers using Hibernate?

Introduction This tutorial we show you how to connect multiple database servers using Hibernate framework. We know Hibernate is an ORM (Object Relational Mapping) framework for the automated persistence of objects in a Java application to the tables in a relational database. Here we will assume that an application will connect to MySQL and SQLServer databases at the same time. You may have different database servers where you need to establish connections using Hibernate ORM framework.

Continue

Hibernate UserType Example using Spring Data JPA

Introduction I am going to show you here what is UserType and why do you need UserType while working with database and web application. In Hibernate UserType Example using Spring Data JPA I will show you how Hibernate allows you to implement and use custom types when built-in types do not satisfy an application’s requirements, or when we want to change the default behavior of a built-in type. As you will see, you can easily implement a custom-type class and then use it in the same way as a built-in…

Continue

org.hibernate.MappingException: No Dialect mapping for JDBC type

Introduction Here I am going to show you how to resolve issue org.hibernate.mapping.exception: No Dialect mapping for JDBC type that occurs in your Hibernate based application due to some types mismatch between database table column and Java field. You might have seen similar kind of exception occurred during performing native queries without entity class and this kind of issue may have been occurred in different databases such as MySQL, Oracle, SQL Server, PostgreSQL etc. Depending upon the database vendor you will get error for JDBC types -4, -9, 7 or…

Continue