This content has been marked as final.
Show 4 replies
-
1. Re: Removing a detached instance
waynebaylor Jul 16, 2007 5:30 PM (in response to idefix-free)The call to merge() returns a managed copy of the entity. You should pass this reference to makeTransient().
... selectedSpielplatz = dao.findById(Long.valueOf(id), false); Spielplatz mergedObject = dao.merge(selectedSpielplatz); dao.makeTransient(mergedObject); ...
-
2. Re: Removing a detached instance
idefix-free Jul 17, 2007 3:34 AM (in response to idefix-free)Still the same error:
public String delete() { String id = FacesContext.getCurrentInstance() .getExternalContext().getRequestParameterMap() .get("selectedId"); selectedSpielplatz = dao.findById(Long.valueOf(id), false); selectedSpielplatz=dao.merge(selectedSpielplatz); dao.makeTransient(selectedSpielplatz); selectedSpielplatz=null; return "list"; }
But I dont understand, that if I load the object(selectedspielplatz) why it is not managed.
Why are the objects always detached?
I tried the same thing with glassfish and toplink and I haven't this problem.
Is it really necessary always to merge before making an operation, or is it possible to reconfigure something, maybe entity manager per session? -
3. Re: Removing a detached instance
wolfc Jul 17, 2007 3:58 AM (in response to idefix-free)SpeilplatzCrudBean is probably a JSF bean. In that case it's living on the other side (in web space). Thus an entity bean which is returned by the DAO is first detached. You should have this code in a session bean.
-
4. Re: Removing a detached instance
idefix-free Jul 17, 2007 3:16 PM (in response to idefix-free)Thanx, that was my problem.
is there something like a designpattern for JSF and J2EE?
Thanx Chris