You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Angelo Chen <an...@yahoo.com.hk> on 2008/02/20 03:01:00 UTC
T5: how to use Hibernate properly?
Hi,
What is the proper way of using hibernate in T5? is following list correct?
1. Don't commit, let Tapestry-Hibernate take care of that.
2. Commit only if you are going to start a thread with Session as well.
3. Use session.save for the new objects, after that, any updates to the
object does not require a save
?
A.C.
--
View this message in context: http://www.nabble.com/T5%3A-how-to-use-Hibernate-properly--tp15580722p15580722.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: how to use Hibernate properly?
Posted by Renat Zubairov <re...@gmail.com>.
You might also consider emplying some kind of concurrency control for
long-living objects, i.e. automatic versionning and attach/detach
strategies.
Renat
On 20/02/2008, Davor Hrg <hr...@gmail.com> wrote:
>
> the reason you should be most concerned is that
> in one request session#1 loads the object
> in other request session#2 loads objects
> if you use relations from second request LazyLoadExceptions will happen
> if you try to force old object from #1 to session#2 you can fix problems
> but this is not recomended approach
>
> to ensure less headaces and complicated ecxeptions (for me at least :) )
>
>
> keeping session free of large objects should concern you only for high
> traffic sites
> and DDR2 is so cheap nowdays, or when in a cluster that serializes
> session.
>
>
> to optimize database access you shoud use hibernate's second level cache
> and not try to hold on to loaded objects for speed.
>
> I tried all those wrong ways of working with hibernate ... and belive me
> it is no fun at all :D
>
> Davor Hrg
>
>
>
>
> On Feb 20, 2008 9:14 AM, Chris Lewis <bu...@gmail.com> wrote:
> > This is a great list to have around - perhaps we can add reasons for
> > each of the steps. Davor I've heard what you're saying before, but I
> > forget the reason behind it (I assume LazyLoadException has something to
> > do with it). Is it for keeping http session free of large objects?
> > Preventing LazyLoadExceptions? What if you make it transient first (if
> > you can without deleting it)?
> >
> >
> > Davor Hrg wrote:
> > > also,
> > >
> > > don't persist hibernate entities, persist keys only
> > >
> > >
> > > On Feb 20, 2008 3:01 AM, Angelo Chen <an...@yahoo.com.hk>
> wrote:
> > >
> > >> Hi,
> > >>
> > >> What is the proper way of using hibernate in T5? is following list
> correct?
> > >>
> > >> 1. Don't commit, let Tapestry-Hibernate take care of that.
> > >> 2. Commit only if you are going to start a thread with Session as
> well.
> > >> 3. Use session.save for the new objects, after that, any updates to
> the
> > >> object does not require a save
> > >>
> > >> ?
> > >>
> > >> A.C.
> > >> --
> > >> View this message in context:
> http://www.nabble.com/T5%3A-how-to-use-Hibernate-properly--tp15580722p15580722.html
> > >> Sent from the Tapestry - User mailing list archive at Nabble.com.
> > >>
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > >> For additional commands, e-mail: users-help@tapestry.apache.org
> > >>
> > >>
> > >>
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> > >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Best regards,
Renat Zubairov
Re: T5: how to use Hibernate properly?
Posted by Davor Hrg <hr...@gmail.com>.
the reason you should be most concerned is that
in one request session#1 loads the object
in other request session#2 loads objects
if you use relations from second request LazyLoadExceptions will happen
if you try to force old object from #1 to session#2 you can fix problems
but this is not recomended approach
to ensure less headaces and complicated ecxeptions (for me at least :) )
keeping session free of large objects should concern you only for high
traffic sites
and DDR2 is so cheap nowdays, or when in a cluster that serializes session.
to optimize database access you shoud use hibernate's second level cache
and not try to hold on to loaded objects for speed.
I tried all those wrong ways of working with hibernate ... and belive me
it is no fun at all :D
Davor Hrg
On Feb 20, 2008 9:14 AM, Chris Lewis <bu...@gmail.com> wrote:
> This is a great list to have around - perhaps we can add reasons for
> each of the steps. Davor I've heard what you're saying before, but I
> forget the reason behind it (I assume LazyLoadException has something to
> do with it). Is it for keeping http session free of large objects?
> Preventing LazyLoadExceptions? What if you make it transient first (if
> you can without deleting it)?
>
>
> Davor Hrg wrote:
> > also,
> >
> > don't persist hibernate entities, persist keys only
> >
> >
> > On Feb 20, 2008 3:01 AM, Angelo Chen <an...@yahoo.com.hk> wrote:
> >
> >> Hi,
> >>
> >> What is the proper way of using hibernate in T5? is following list correct?
> >>
> >> 1. Don't commit, let Tapestry-Hibernate take care of that.
> >> 2. Commit only if you are going to start a thread with Session as well.
> >> 3. Use session.save for the new objects, after that, any updates to the
> >> object does not require a save
> >>
> >> ?
> >>
> >> A.C.
> >> --
> >> View this message in context: http://www.nabble.com/T5%3A-how-to-use-Hibernate-properly--tp15580722p15580722.html
> >> Sent from the Tapestry - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> >
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: how to use Hibernate properly?
Posted by Chris Lewis <bu...@gmail.com>.
This is a great list to have around - perhaps we can add reasons for
each of the steps. Davor I've heard what you're saying before, but I
forget the reason behind it (I assume LazyLoadException has something to
do with it). Is it for keeping http session free of large objects?
Preventing LazyLoadExceptions? What if you make it transient first (if
you can without deleting it)?
Davor Hrg wrote:
> also,
>
> don't persist hibernate entities, persist keys only
>
>
> On Feb 20, 2008 3:01 AM, Angelo Chen <an...@yahoo.com.hk> wrote:
>
>> Hi,
>>
>> What is the proper way of using hibernate in T5? is following list correct?
>>
>> 1. Don't commit, let Tapestry-Hibernate take care of that.
>> 2. Commit only if you are going to start a thread with Session as well.
>> 3. Use session.save for the new objects, after that, any updates to the
>> object does not require a save
>>
>> ?
>>
>> A.C.
>> --
>> View this message in context: http://www.nabble.com/T5%3A-how-to-use-Hibernate-properly--tp15580722p15580722.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>
Re: T5: how to use Hibernate properly?
Posted by Davor Hrg <hr...@gmail.com>.
also,
don't persist hibernate entities, persist keys only
On Feb 20, 2008 3:01 AM, Angelo Chen <an...@yahoo.com.hk> wrote:
>
> Hi,
>
> What is the proper way of using hibernate in T5? is following list correct?
>
> 1. Don't commit, let Tapestry-Hibernate take care of that.
> 2. Commit only if you are going to start a thread with Session as well.
> 3. Use session.save for the new objects, after that, any updates to the
> object does not require a save
>
> ?
>
> A.C.
> --
> View this message in context: http://www.nabble.com/T5%3A-how-to-use-Hibernate-properly--tp15580722p15580722.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org