Firlefanz! Of couse, Urlich sayed the through, but in this context its not right. Dominik, dont @Persist-ing the entity, you will see, it works.
with regards Sven Homburg Founder of the Chenille Kit Project http://chenillekit.codehaus.org 2010/2/8 Ulrich Stärk <u...@spielviel.de> > You really should consult Hibernate's documentation and especially > understand the persistent object lifecycle (Java Persistence with Hibernate > is an excellent book). Saving an object will persist it to the database > (probably including generating an ID and updating the object). Saving it > again will try to save an object with the same ID to the database - thus the > error. What you want is something like Hibernate's update() or > saveOrUpdate() or JPA's merge(). > > Uli > > On 08.02.2010 11:39 schrieb Dominik Gätjens: > > for sure, but if i persist an object in the http session, i've got the >> same object again after page reload? So i should be able to save it in the >> hibernate session because it is the same Object? >> >> e.g. >> first page load -> get ObjectA from DB -> save ObjectA in http-Session >> second page load -> get ObjectA from http-Session -> save ObjectA in DB >> >> but this throws an "a different object with the same identifier value was >> already associated with the session:" Exception. >> >> >> So according to Jose i don't get the right Object (that is bound to the >> hibernate-session) from the http-session!? >> >> >> >> -----Ursprüngliche Nachricht----- >> Von: Ulrich Stärk [mailto:u...@spielviel.de] >> Gesendet: Montag, 8. Februar 2010 11:31 >> An: Tapestry users >> Betreff: Re: AW: Updating Hibernate Entites >> >> @Persist is for persisting objects in the Http session, not for persisting >> entities in a database. >> >> Uli >> >> On 08.02.2010 10:28 schrieb Dominik Gätjens: >> >>> I'm using the chenillekit hibernate daos, and there is no explicit update >>> method, so i thought save() should do this job. >>> >>> I don't understand why there is a new Object if I annotade the config >>> with @Persist. Shouldn't it be saved in the Session? >>> >>> btw: i found a possible solution with page activation context: >>> >>> void onActivate(Long configId){ >>> config=configDAO.doRetrieve(configId,false); >>> >>> } >>> Long onPassivate(){ >>> return config.getId(); >>> } >>> >>> but I still want to know why it won't work with @Persist? >>> >>> -----Ursprüngliche Nachricht----- >>> Von: Jose Luis Sanchez [mailto:joseluis.sanc...@m-centric.com] >>> Gesendet: Montag, 8. Februar 2010 10:21 >>> An: Tapestry users >>> Betreff: Re: Updating Hibernate Entites >>> >>> You are trying to save a new object while using the old object id , >>> what would end in two entities with same id - something not possible. >>> You should call your DAO update method , instead of save. >>> >>> >>> Hello List, >>>> >>>> >>>> >>>> i'm trying to update an Hibernate-Object but alway get an "a different >>>> object with the same identifier value was already associated with the >>>> session:" Exception. >>>> >>>> >>>> >>>> My Form-Code looks like: >>>> >>>> @Inject >>>> >>>> private ConfigurationDAO configDAO; >>>> >>>> @Persist >>>> >>>> @Property >>>> >>>> private Configuration config; >>>> >>>> >>>> >>>> void onSuccessFromConfigForm(){ >>>> >>>> config.setEditDate(new Date()); >>>> >>>> configDAO.doSave(config); >>>> >>>> } >>>> >>>> >>>> >>>> void onActivate(Long configId){ >>>> >>>> config=configDAO.doRetrieve(configId,false); >>>> >>>> } >>>> >>>> void onActivate(){ >>>> >>>> configs = configDAO.findAll(); >>>> >>>> if(config==null) >>>> >>>> config=new >>>> de.leomedia.leotipp.model.Configuration(); >>>> >>>> } >>>> >>>> >>>> >>>> can anyone give me a lead into the right direction? >>>> >>>> >>>> >>>> thanks, Dominik >>>> >>>> >>>> >>>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >>> For additional commands, e-mail: users-h...@tapestry.apache.org >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >>> For additional commands, e-mail: users-h...@tapestry.apache.org >>> >>> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >> For additional commands, e-mail: users-h...@tapestry.apache.org >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >> For additional commands, e-mail: users-h...@tapestry.apache.org >> >> > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >