You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Sébastien Piller <pi...@hmcrecord.ch> on 2008/02/13 08:59:50 UTC

Handle Hibernate transaction in wicket

Hello,

I'm searching for a best practice to integrate some hibernate 
transaction with Wicket. I'd like to implement the "session-per-request" 
that is described here 
http://www.hibernate.org/hib_docs/v3/reference/fr/html_single/#tutorial-firstapp-workingpersistence

I think I can commit the transaction and close the session on the 
"onAfterRender" method. But where is the best place to start it? On the 
first line of the constructor? Or in the onBeforeRender (I think not)? 
Anywhere else?

And what about the ajax queries? I need to recreate a new transaction 
for each ajax request, need I?

Thank you a lot for your think :)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Handle Hibernate transaction in wicket

Posted by Igor Vaynberg <ig...@gmail.com>.
see databinder.net

-igor


On Feb 12, 2008 11:59 PM, Sébastien Piller <pi...@hmcrecord.ch> wrote:
> Hello,
>
> I'm searching for a best practice to integrate some hibernate
> transaction with Wicket. I'd like to implement the "session-per-request"
> that is described here
> http://www.hibernate.org/hib_docs/v3/reference/fr/html_single/#tutorial-firstapp-workingpersistence
>
> I think I can commit the transaction and close the session on the
> "onAfterRender" method. But where is the best place to start it? On the
> first line of the constructor? Or in the onBeforeRender (I think not)?
> Anywhere else?
>
> And what about the ajax queries? I need to recreate a new transaction
> for each ajax request, need I?
>
> Thank you a lot for your think :)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Handle Hibernate transaction in wicket

Posted by James Carman <ja...@carmanconsulting.com>.
It sounds like you're looking for "transaction-per-request" and not
"session-per-request."  The "session-per-request" part is easy.  Just
use the OpenSessionInViewFilter from Spring (as stated by someone else
on this thread).  The OpenSessionInViewFilter doesn't begin a
transaction for you automatically.  It merely opens the session and
closes it for you.


On 2/13/08, Sébastien Piller <pi...@hmcrecord.ch> wrote:
> Hello,
>
> I'm searching for a best practice to integrate some hibernate
> transaction with Wicket. I'd like to implement the "session-per-request"
> that is described here
> http://www.hibernate.org/hib_docs/v3/reference/fr/html_single/#tutorial-firstapp-workingpersistence
>
> I think I can commit the transaction and close the session on the
> "onAfterRender" method. But where is the best place to start it? On the
> first line of the constructor? Or in the onBeforeRender (I think not)?
> Anywhere else?
>
> And what about the ajax queries? I need to recreate a new transaction
> for each ajax request, need I?
>
> Thank you a lot for your think :)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Handle Hibernate transaction in wicket

Posted by James Carman <ja...@carmanconsulting.com>.
Actually, Spring lets you (more importantly them) not worry about the
transaction stuff at all.  The person (you, perhaps) who is wiring
things together can add in the transaction stuff in the XML file.

On 2/20/08, Sébastien Piller <pi...@hmcrecord.ch> wrote:
> Yes, I read a bit about Spring some time ago, but atm I'm working on a
> project that will be released soon. I can't afford to rewrite half my
> code on the lasts weeks ;)
>
> Next time, I'll take some time to getting started with it. I'm sure it's
> worth, that's what I read all the day. But I must consider my
> colleagues, too... They are not very very interested with dev, and
> already have difficulties to write php... so, with Spring, they will
> shot themselves :)
>
> Thx
>
> James Carman a écrit :
> > Once you get used to Spring, you'll really appreciate it.  I wouldn't
> > write it off as too difficult if I were you.  It's definitely worth
> > learning (and it helps your resume; it's in high demand).
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Handle Hibernate transaction in wicket

Posted by Sébastien Piller <pi...@hmcrecord.ch>.
Yes, I read a bit about Spring some time ago, but atm I'm working on a 
project that will be released soon. I can't afford to rewrite half my 
code on the lasts weeks ;)

Next time, I'll take some time to getting started with it. I'm sure it's 
worth, that's what I read all the day. But I must consider my 
colleagues, too... They are not very very interested with dev, and 
already have difficulties to write php... so, with Spring, they will 
shot themselves :)

Thx

James Carman a écrit :
> Once you get used to Spring, you'll really appreciate it.  I wouldn't
> write it off as too difficult if I were you.  It's definitely worth
> learning (and it helps your resume; it's in high demand).

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Handle Hibernate transaction in wicket

Posted by James Carman <ja...@carmanconsulting.com>.
Once you get used to Spring, you'll really appreciate it.  I wouldn't
write it off as too difficult if I were you.  It's definitely worth
learning (and it helps your resume; it's in high demand).

On 2/20/08, Pills <pi...@hmcrecord.ch> wrote:
>
> Thank you all for your ideas.
>
>
> At the moment, I handle it manually (transaction and session), and until
> now, I don't got much problems.
>
> I don't want to use anything from spring, as it seems a lot more difficult
> than anything else in my project.
>
> I've put a closeSession on the onAfterRender method, and every part of my
> code that use the DB are properly surrounded with transactions... I don't
> have any problem, and even if it is a bit slower than a best practice, it's
> enough for me ;)
> --
> View this message in context: http://www.nabble.com/Handle-Hibernate-transaction-in-wicket-tp15451303p15590755.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Handle Hibernate transaction in wicket

Posted by Pills <pi...@hmcrecord.ch>.
Thank you all for your ideas.


At the moment, I handle it manually (transaction and session), and until
now, I don't got much problems.

I don't want to use anything from spring, as it seems a lot more difficult
than anything else in my project. 

I've put a closeSession on the onAfterRender method, and every part of my
code that use the DB are properly surrounded with transactions... I don't
have any problem, and even if it is a bit slower than a best practice, it's
enough for me ;)
-- 
View this message in context: http://www.nabble.com/Handle-Hibernate-transaction-in-wicket-tp15451303p15590755.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Handle Hibernate transaction in wicket

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
see blog tutorial on howto set this up with wicket...:)

Martijn Lindhout wrote:
> I use Spring's OpenSessionInViewFilter
>
> 2008/2/19, Andrew Williams <an...@handyande.co.uk>:
>   
>> I use onBeginRequest and onEndRequest from the WebRequestCycle, seems
>> to work well.
>>
>> Andy
>>
>> On 13 Feb 2008, at 07:59, Sébastien Piller wrote:
>>
>>     
>>> Hello,
>>>
>>> I'm searching for a best practice to integrate some hibernate
>>> transaction with Wicket. I'd like to implement the "session-per-
>>> request" that is described here
>>>       
>> http://www.hibernate.org/hib_docs/v3/reference/fr/html_single/#tutorial-firstapp-workingpersistence
>>     
>>> I think I can commit the transaction and close the session on the
>>> "onAfterRender" method. But where is the best place to start it? On
>>> the first line of the constructor? Or in the onBeforeRender (I think
>>> not)? Anywhere else?
>>>
>>> And what about the ajax queries? I need to recreate a new
>>> transaction for each ajax request, need I?
>>>
>>> Thank you a lot for your think :)
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>       
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>     
>
>
>   

-- 
Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Handle Hibernate transaction in wicket

Posted by Martijn Lindhout <ml...@jointeffort.nl>.
I use Spring's OpenSessionInViewFilter

2008/2/19, Andrew Williams <an...@handyande.co.uk>:
>
> I use onBeginRequest and onEndRequest from the WebRequestCycle, seems
> to work well.
>
> Andy
>
> On 13 Feb 2008, at 07:59, Sébastien Piller wrote:
>
> > Hello,
> >
> > I'm searching for a best practice to integrate some hibernate
> > transaction with Wicket. I'd like to implement the "session-per-
> > request" that is described here
> http://www.hibernate.org/hib_docs/v3/reference/fr/html_single/#tutorial-firstapp-workingpersistence
> >
> > I think I can commit the transaction and close the session on the
> > "onAfterRender" method. But where is the best place to start it? On
> > the first line of the constructor? Or in the onBeforeRender (I think
> > not)? Anywhere else?
> >
> > And what about the ajax queries? I need to recreate a new
> > transaction for each ajax request, need I?
> >
> > Thank you a lot for your think :)
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Martijn Lindhout
JointEffort IT Services
http://www.jointeffort.nl
mlindhout@jointeffort.nl
+31 (0)6 18 47 25 29

Re: Handle Hibernate transaction in wicket

Posted by Andrew Williams <an...@handyande.co.uk>.
I use onBeginRequest and onEndRequest from the WebRequestCycle, seems  
to work well.

Andy

On 13 Feb 2008, at 07:59, Sébastien Piller wrote:

> Hello,
>
> I'm searching for a best practice to integrate some hibernate  
> transaction with Wicket. I'd like to implement the "session-per- 
> request" that is described here http://www.hibernate.org/hib_docs/v3/reference/fr/html_single/#tutorial-firstapp-workingpersistence
>
> I think I can commit the transaction and close the session on the  
> "onAfterRender" method. But where is the best place to start it? On  
> the first line of the constructor? Or in the onBeforeRender (I think  
> not)? Anywhere else?
>
> And what about the ajax queries? I need to recreate a new  
> transaction for each ajax request, need I?
>
> Thank you a lot for your think :)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org