Common Hibernate Exceptions 1. Introduction In this tutorial, we’ll discuss some common exceptions we can encounter while working with Hibernate. We’ll review their purpose and some common causes. Additionally, we’ll look into their solutions. 2. Hibernate Exception Overview Many conditions can cause exceptions to be thrown while using Hibernate. These… Continue Reading hibernate-exceptions

Dynamic Mapping with Hibernate 1. Introduction In this article, we’ll explore some dynamic mapping capabilities of Hibernate with the @Formula, @Where, @Filter and @Any annotations. Note that although Hibernate implements the JPA specification, annotations described here are available only in Hibernate and are not directly portable to other JPA implementations.… Continue Reading hibernate-dynamic-mapping

Hibernate Aggregate Functions 1. Overview Hibernate aggregate functions calculate the final result using the property values of all objects satisfying the given query criteria. Hibernate Query Language (HQL) supports various aggregate functions – min(), max(), sum(), avg(), and count() in the SELECT statement. Just like any other SQL keyword, usage of these functions… Continue Reading hibernate-aggregate-functions

Hibernate: save, persist, update, merge, saveOrUpdate 1. Introduction In this article we will discuss the differences between several methods of the Session interface: save, persist, update, merge, saveOrUpdate. This is not an introduction to Hibernate and you should already know the basics of configuration, object-relational mapping and working with entity… Continue Reading hibernate-save-persist-update-merge-saveorupdate

Custom Types in Hibernate and the @Type Annotation Persistence Hibernate   1. Overview Hibernate simplifies data handling between SQL and JDBC by mapping the Object Oriented model in Java with the Relational model in Databases. Although mapping of basic Java classes is in-built in Hibernate, mapping of custom types is often complex.… Continue Reading hibernate-custom-types

Deleting Objects with Hibernate 1. Overview As a full-featured ORM framework, Hibernate is responsible for lifecycle management of persistent objects (entities), including CRUD operations such as read, save, update and delete. In this article, we explore various ways in which objects may be deleted from a database using Hibernate and… Continue Reading delete-with-hibernate

Persist a JSON Object Using Hibernate 1. Overview Some projects may require JSON objects to be persisted in a relational database. In this tutorial, we’ll see how to take a JSON object and persist it in a relational database. There are several frameworks available that provide this functionality, but we… Continue Reading hibernate-persist-json-object