org.hibernate.Query.setInteger() function doesn't allow your integer to be null whereas org.hibernate.Query.setParameter(..., ..., Hibernate.INTEGER) does.
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:
//... Query oQuery = session.createSQLQuery("UPDATE Person SET age=:age WHERE id:=id"); oQuery.setInteger("id", id); // id is guaranteed to exist and it is an integer. oQuery.setParameter("age", age, Hibernate.INTEGER); // age may be null or an integer. //... int iRowCnt = oQuery.executeUpdate(); //...