-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: detached entity passed to persist on a query
PostPosted: Wed Oct 31, 2012 9:22 am 
Newbie

Joined: Fri Apr 13, 2012 11:50 am
Posts: 2
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.