I have done a fair amount of reading today on the topic again and
developed a few simple classes to support my service, model, and dao
architecture for using Hibernate 3.3.2 and Spring 2 with Struts2. The
problem I am currently facing is I get a detached error when deleting
an object and I get a null pointer exception in SessionImpl.java when
I try to locate an object by its id.
/* GenericDAO.java */
public T findById(Object id) {
return(getEntityManager().find(clazz, id));
}
public void delete(T entity) {
getEntityManager().remove(entity);
}
Some posts I have seen say for the delete, you should use
getReference() or merge() in order to get an association to the entity
before you call the remove() method. I attempted to use the same type
of logic with getReference() during the findById() and it failed.
Am I missing something in my configuration with Hibernate/Spring with
respect to the session factory or something that I need to revisit?
It really seems as though I may have a missing component or a poor
configuration somewhere.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]