In Eclipse, include the following JARs:

Data type int, double, float are not nullable


When you use primitive data types(i.e int, double and float) with hibernate, you will not be able to convert them to null because Java doesn't allow them to be null. In order for these data types to be null, use their object counter part.(i.e Integer, Double, Float). However, it is very expensive to use the object data type. Therefore, use them only when needed.

SQL IN() operator


Here is an example of how you define a list of values in hibernate for the SQL IN() operator:

org.hibernate.Query.setInteger VS org.hibernate.Query.setParameter(..., ..., Hibernate.INTEGER)


org.hibernate.Query.setInteger() function doesn't allow your integer to be null whereas org.hibernate.Query.setParameter(..., ..., Hibernate.INTEGER) function allows your integer to be null.

For example, if you are parsing a file to retrieve the age of a person and then update that age into your database. However, the age is not always written in the file. Therefore, the age is nullable. Here is a code example using setParameter() function to deal with nullable integer:

Subscribe to RSS - hibernate