Thank you matt, that is I am using, the evict() method. But Hibernate
silently flushes and may commit (if autocommit=true) the changes before a
session.find(..), so you have to set the session with a FlushMode=COMMIT to
prevent from this. Thus, you  can evict() the object if you detects errors
from validation.
Richard.

-----Message d'origine-----
De : [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] la part de
Matt Ho
Envoye : jeudi 9 octobre 2003 12:12
A : [EMAIL PROTECTED]
Objet : Re: [OS-webwork] UPDATED: hibernate/webwork2 best practices


Fred Lamuette wrote:
> I'm using almost the same pattern as you, I've created an interceptor that
> loads the model in the action
> (detection of the id paramter and extension of the ModelDriven interface
to
> add setModel(..) and getModelClass() method, thus I can load and store
> easily my entity in my ModelDriven action). It works really great.
>
> The only problem is the following one :
> 1/ My model is populated in my interceptor
> 2/ The validation interceptor finds errors on my model
> 3/ How can I elegantly "rollback" the changes made on my model whithout
> Hibernate saves the change in db when closing the session, in the after
> method?

One way to prevent Hibernate from saving these unwanted changes is to
evict the object from the session cache.

Iterator cats = sess.iterate("from eg.Cat as cat"); //a huge result set
while ( cats.hasNext() ) {
     Cat cat = (Cat) iter.next();
     doSomethingWithACat(cat);
     sess.evict(cat);
}

M




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to