-->
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.  [ 2 posts ] 
Author Message
 Post subject: Using hibernate session to hold table in memory.
PostPosted: Mon Jul 13, 2009 4:39 am 
Newbie

Joined: Mon Jul 13, 2009 4:29 am
Posts: 1
Hi
I need to hold db table in memory due to performance problems (many selects on this table each iteration).
I thought to use hibernate session for this , when the application is up i will load all objects into the session (select * from table) and keep the session open so my data will be updated.In runtime i will use find command.
What do think on this solution ? if i use @version does it qurey the db on every find ? (so my performance will remain poor).


Top
 Profile  
 
 Post subject: Re: Using hibernate session to hold table in memory.
PostPosted: Wed Jul 15, 2009 1:23 pm 
Senior
Senior

Joined: Tue Aug 01, 2006 9:24 pm
Posts: 120
I think you might misunderstand how a session works. Sessions do not automatically update the database you need to actually call update or save on an persistent object for this to happen.

"Select *" is usually slower than declaring each field. You might want to try declaring the fields or annotation.

If your annotations are large then include in the Select only the Annotations you actually need. So that hibernate doesn't load the whole hierarchy.

Use lazy loading properly. Don't lazy load objects you always need. And do lazy load objects that you rarely need.

I am not sure about @Version I haven't used it, but take a look through the hibernate documentation I am sure it's in there somewhere.

_________________
Please rate my replies as I need points for all of my questions also.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.