Hello,
Quick question, why would i get this exception on a query?
javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: com.work.model.WorkPkg
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1361) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1289) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:261) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
I expected to see this when i tried to persist or merge not when i query.
My code looks like this :
Code:
Query q = entityManager.createQuery("select w from ChargeNumber w where w.chargeNumber = :text");
q.setParameter("text", businessKey);
List<ChargeNumber> myList = q.getResultList();
and the exception points to the q.getResultLIst().
Not sure why, any thoughts.
Thanks