Fair enough, I have something similar going right now. But this still leaves one problem:

If StaleObjectStateException is thrown inside Form.onSubmit() I am forced to handle it (and retry) inside onSubmit() as opposed to (ideally) handling it outside Wicket and retrying the entire HTTP request. Right now I have a whole bunch of transaction blocks defined *inside* my application code which is a disaster. It kills readability as well as making my application aware of transactions when ideally it shouldn't have to care about it.

In http://www.hibernate.org/42.html they write: "Our goal really is to remove any transaction demarcation code from the data access code" which is exactly what I'm trying to accomplish...

Gili

Igor Vaynberg wrote:
Instead of doing this:

Onbeginrequest() { mysession=factory.opensession();
mysession.begintransaction(); }

Session getSession() { return mysession; }

Do this:

Onbeginrequest() { mysession=null; }

Session getSession() { if (mysession==null) {
mysession=factory.opensession(); mysession.begintransaction(); } return
mysession; }

Then when an error occurs just reset mysession back to null and next time
you need one you will get a fresh one


-Igor



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gili
Sent: Wednesday, October 19, 2005 11:44 PM
To: [EMAIL PROTECTED]
Subject: [Wicket-user] Wicket, Hibernate and StaleObjectStateException

Hi,

I'm trying to figure out how to handle StaleObjectStateException in the context of Wicket. Using the current-state pattern as reference (http://www.hibernate.org/42.html) if a StaleObjectStateException is thrown, I'd like to rollback the transaction, close the session, open a new session and transaction and retry the operation. Ideally I want to keep this logic completely out of the Wicket code. I simply don't see how this can be done.

For example, say I have a page containing a Form and Form.onSubmit() is invoked and in its body StaleObjectStateException is thrown. Following the "Session per HTTP request" pattern, we're in a new HTTP request (I
think) but I don't think Wicket will invoke beginRequest() and
endRequest() before and after Form.onSubmit(). Even if it did, I'd have no way to signal to Wicket to retry the onSubmit() operation by catching the exception outside it.

So on the one hand, I don't want to catch the exceptions inside the Wicket code. On the other hand, I can't retry the operation if I catch the exception outside the Wicket code.

        Your advice would be appreciated.

Thank you,
Gili
--
http://www.desktopbeautifier.com/


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user








-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user


--
http://www.desktopbeautifier.com/


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to