one-to-many class mapping This article explains how to map two classes in collection mapping. In this example one Author object has the list of Book objects. Both the classes are mapped and will be inserted together into the database. Here this example uses Bag as the collection type. Other collection types available are Set,List,Array. Look […]

Comparison operators HQL supports all the operators used in the SQL language. But, Criteria API doesn’t support the arithmetic expressions. Apart from that, it is easy to use other operators in the Criteria API itself. This tips provides few basic example programs on using the operators. JavaBeatHibernateExample.java also read: Introduction to Hibernate Hibernate Interview Questions […]

null and not null check While checking for the null and not null values in the Hibernate API, we have to be careful and there is chance for misunderstanding. This tips explains how to compare the null values in the Hibernate query. also read: Introduction to Hibernate Hibernate Interview Questions Interceptors in Hibernate Hibernate Books […]

Named Parameters in Hibernate Query There is two types of query parameters binding in the Hibernate Query. One is positioned parameter and another one is named parameter. But, hibernate recommend to use the named parameters since it is more flexible and powerful compare to the positioned parameter. Here we will look into the named parameter […]

Pagination in Hibernate Query API Pagination is the very common problem for the most of the eneterprise applications.When we are retrieving thousands of records from the database, it is not good idea to retrieve all the records at the same time. So, we have to implement some sort of pagination concept in your application to […]

Create Query in Hibernate To create query in the Hibernate ORM framework, there is three different types. The following are the three ways to create query instance: session.createQuery() session.createSQLQuery() session.createCriteria() We will look into the details of each category in detail. also read: Introduction to Hibernate Hibernate Interview Questions Interceptors in Hibernate Hibernate Books session.createQuery() […]

Hibernate Criteria Example Criteria APIs in the hibernate framework is useful for creating the dynamic query to execute.It is an alternative way to write the queries without using HQL. The queries are generated at runtime and excuted on the fly. Application developer need not worry about writing the query in hand, he/she just need to […]

Hibernate Configuration Using XML files for configuring hibernate application is the most widely used approach. This is simple one and less whanges needed in the future. There is two types of configuration we can do using XML files. one is non-managed environment and another one is for managed environment. Here we will explain about the […]

This example program shows how to insert multiple rows using the batch processing in hibernate. when there are thousand of rows to be persisted, everytime iterating and inserting will cause the memory problem. Hibernate stores all the persisted objects in the memory. To avoid this problem use batch processing in the hibernate. also read: Introduction […]

Hibernate Configuration This example demonstrates how to configure hibernate framework for running a simple standalone program. Here the sample program uses programmatic configuration to set all the properties required for running hibernate. Also the example uses derby as the database to connect and update the values. This is not the big change, you only have […]