Hi all,
I have been looking for a while to find a possible solution to the problem of retrieving an int (a primitive type) from a database table. The database table contains some nulls and that's where I got "IllegalArgumentException"
This is the mapping of the property posX (in the table this is a FLOAT) which I plan to map to a fload primitive type
the mapping for the class contains:
<property name="posX" column="posX" />
the java class contains
private long posX;
plus the usual getter/setter for this field.
In the Generic DAO class the following piece of code is giving an error in the "return criteria.list();" line. Guess that the problem is that there an assignment of a null value to a primitive field.
Is there a way to "shield" the application against this kind of problems ?
How can I define the posX field / or modify the hibernate mapping file to avoid this problem ?
public List<T> findByCriterion(final Criterion... criterions) {
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException, SQLException {
Criteria criteria = session.createCriteria(getPersistentClass());
criteria.add(Restrictions.disjunction());
for (Criterion criterion : criterions) {
criteria.add(criterion);
}
return criteria.list();
}
});
}
Thank you in advance for any solutions.
Davide


Reply With Quote
So now the posX is defined as Float wrapper. Now the getter and setter have been changed as this.