-
HibernateTemplate.load
Hello All
I think within HibernateTemplate has one bug in load method, when I call load method with Composite PrimaryKey in ID, the return object is null, with HibernateObjectRetrievalFailureException Exception. but a ensure that ID is with valid data.
Code:
public Object retrieve(Object dataObject, Serializable id) {
try {
if (dataObject != null && id != null) {
HibernateTemplate template = new HibernateTemplate (getSessionFactory());
retorno = template.load(dataObject.getClass(),id);
}
}
catch (HibernateObjectRetrievalFailureException e) {
retorno = null;
}
catch (Exception e) {
e.printStackTrace();
}
return retorno;
}
Here the code where a call the above method
Code:
VendedorClientePOPK vendedorClientePK = new VendedorClientePOPK();
VendedorClientePO vendedorCliente = new VendedorClientePO();
vendedorClientePK.setCodCliente( Util.getCnpj(nrCgc,nrFil,nrDc) );
vendedorClientePK.setCodVendedor(codVendedor);
VendedorClientePO vc = (VendedorClientePO) getGenericDao().retrieve(vendedorCliente, vendedorClientePK);
-
HibernateTemplate.load() is just a simple wrapper around Hibernte's Session.load(), just ensuring that the Session lifecycle is properly managed.
If you are getting no results back from your load, it's a Hibernate config/usage issue, and nothing to do with Spring...