-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: Lazy Load Open Session Web Application ?!?
PostPosted: Thu Apr 08, 2004 9:30 am 
Hello Everybody, developers.

I`m looking very much forward to hear:

In a web application, I`d like to have an open hibernateSession for

more than one Thread for a user. (That `d be wonderful in a matter of

performance considering the usage of the LazyLoad)

I tried to bind the user`s Hibbernate session (opened but

disconnected) to his httpSession`s id (key) stored in a Map. When the

user closes his browser`s window I use the sessionDestroyed from the

Application Server to get his httpSession Id and remove the

hibernateSession from the Map.

The thing that happens is that when I restore the opened

hibernateSession in another thread and reconnect and start a new

Transaction it says it cannot persist Integer.

Do u guys have a better way to have an opened hibernateSession ()

for more than one thread in a web application? ( Cos`I cannot use the

Thread Local to store the hibernateSession right? )

Or can this problem (can`t persist Integer) be solved ?

Thanks in Advance,

from Brazil,

Luiz.

Tip: what i`m trying to do is: if I get Some client`s name and surname in a table and then if the system`s user clicks in a link (client`s name) I could use (throught Lazy Loaded Object in httpSession) the same Object that brought me the listing to get the clients details and I `d have a the performance gain ....


Tip2: Hibernate version 2.1.2
Database MAnager: SQLServer 2000.


Top
  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 10:06 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Don't use session on several thread you'll be in trouble.
Did you check the Second level cache capability

_________________
Emmanuel


Top
 Profile  
 
 Post subject: COME ON DEVELOPERS!
PostPosted: Tue Apr 20, 2004 12:55 pm 
I`m going to check it out tnx.

What if I tried to encapsulate my Object`s hibernateSession inside my

Object (considering my Object a VO ).

Implementing LifeCycle and using it`s listeners to be able to have a

reference to his hibernateSession and taking care of it encapsulating,

connecting, disconnecting, refreshing the cache... (transparently to all the

other developers that are going to manipulate that VO).

This way I could maintain an Object with reference to all my other

classes in the httpSession and using LazyLoad to make things go faster.

Can u give me a way, clue, piece of code hint or whatever to make it

work?

Thank you very Much !

:Luiz.


Top
  
 
 Post subject:
PostPosted: Wed Apr 21, 2004 4:32 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Do you know that hibernate mlanage the cache (1st and 2nd) for you?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 22, 2004 9:40 am 
Yes I read ALL the reference guide many times.
What I don`t know is the implications it has in the model i`m trying to create. I can`t find what the cache levels ( session and query ) have to do with the ARCHITECTURE i`m trying to design.
I`ll get deeper in that though.

Tnx,

:Luiz.


ps: I`m having a 'feeling' u didn`t understand what i`m trying to do here after all. Anyway the only good reference about cache level one and two is looking straight to the code isn`t it?


Top
  
 
 Post subject:
PostPosted: Thu Apr 22, 2004 3:59 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You're right I did not really get your point.

Do you want to have a lazy loaded graph shared by several users ?
Then the second level cache is ok.
Open a session
load() by id ; if the object is in cache it will be returned
navigate your graph, if the subobject is in cache it will be used, otherwise the session connection will request the DB.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 22, 2004 4:33 pm 
I N D E E D !

Now U got me !
I`ll implement it in my next subproject and make some performance tests.

Tnx for ur consideration,

[]`s,

:Luiz.


Top
  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.