I'm using the Hibernate Tool 3.1 to map an old database(oracle 9.2).
The database didn't had any primary keys defined, so I use hibernate.reveng.xml to define the colums that make an unique key(with composite-id).
With hibernate tools I create my 'Domain Code' and '.hbm.xml' files.
Now when I try to get an object with get and I give a long and a Short variable, I get my Object back without any problems.
But when I want to get the object where one of the variable has the value 'null' in my database, I get a 'java.lang.NullPointerException'.
When I look in my database there is only one row that corresponds with it.
I have asked around I have heard that hibernate has problems with null values. Is there any way around, so the null values aren't a problem?
Example:
Part of TestClass working code:
Code:
Kssv k = kssvDao.getKssv(new KssvId(11, new Short("1")));
Part of TestClass failling code:
Code:
Kssv k = kssvDao.getKssv(new KssvId(11, null));
Constructor of KssvId
Code:
public KssvId(long kssvnr, Short kssvagentnr) {
this.kssvnr = kssvnr;
this.kssvagentnr = kssvagentnr;
}
Part of KssvDaoImpl:
Code:
public Kssv getKssv(KssvId inId) {
Validate.notNull(inId, "inId cannot be null");
try {
return (Kssv) this.getHibernateTemplate().get(Kssv.class, inId);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}