-->
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: PersistentObjectException: detached entity passed to persist
PostPosted: Wed Nov 04, 2009 2:15 pm 
Newbie

Joined: Tue Nov 03, 2009 9:59 am
Posts: 5
Hi all ,

I am having this exception thrown in my face whenever I try to persist my object as such


public String saveUser()

{


if (user.getPassword().equals(verify) )
{


List existing = em.createQuery(query)

.setParameter("username", user.getUserName())

.getResultList();

if (existing.size()==0)
{
System.out.println(":: ABOUT TO SAVE ::::");
user.setCreatedBy(credentials.getUsername());
user.setCreatedDate(new java.util.Date());
//em.merge(user);
em.persist(user);

return "users";


}
else

{

facesContext.addMessage(null, new FacesMessage("username already exists"));

return null;

}

}

else
{

facesContext.addMessage(null, new FacesMessage("re-enter your password"));

verify=null;

return null;

}

}

javax.ejb.EJBTransactionRolledbackException: org.hibernate.PersistentObjectException: detached entity passed to persist:



However whenever I call em.merge(user); it ends up doing an update.

Pls can I get help to put this issue to rest?

Thank you have a wonderful day


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.