Archive | July 26th, 2008

Collection Mapping in Hibernate : one-to-many

July 26, 2008

0 Comments

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 [...]

email

Comparison operators in Hibernate

July 26, 2008

0 Comments

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 1 2 3 4 5 6 7 8 [...]

NULL and NOT NULL comparison in the Hibernate API

July 26, 2008

0 Comments

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. In Java language, if object==null will return the proper value if it is [...]

How to use named parameters and named query in Hibernate?

July 26, 2008

0 Comments

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

July 26, 2008

1 Comment

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 [...]

Three ways to create query in Hibernate

July 26, 2008

12 Comments

Create Query in Hibernate To create query in the Hibernate ORM framework, there is three different types. The folloing are the three ways to create query instance: 1)session.createQuery() 2)session.createSQLQuery() 3)session.createCriteria() We will look into the details of each category in detail. session.createQuery() The method createQuery() creates Query object using the HQL syntax. Fro example session.createSQLQuery() [...]