Get your CodeRanch badge!*
The moose likes Performance and the fly likes Hibernate: When should I load my records? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "Hibernate: When should I load my records?" Watch "Hibernate: When should I load my records?" New topic
Author

Hibernate: When should I load my records?

Mario Schwaiger
Greenhorn

Joined: Jun 14, 2010
Posts: 11
Hi!
I'm developing a web project in JSP which uses Hibernate to cache and edit data records. The user just sees one record including all its lines on a page - if he wants to see another record the page is reloaded. Every record contains a list of 1-7 lines of data from a(n updateable) view which needs to be changed sometimes. Now it comes to the point where I have to design the efficiency of the whole thing. I guess I have three (four?) options:

1. Load the whole data in the beginning and just perform list.add/deletes as something occurs. Here would the question be how the data is loaded in this moment. Just by using session.createQuery( "Select E From Elements E") it's not really queued. Also I am a bit afraid of potential timeouts. I am using c3p0 and as a timeout occurs it can handle it (even though it takes ~30s until the successful reconnect...)

2. The other option would be to load and change everything on demand and use HQL to catch the Item of desire in the moment the user changes/inserts a record:


Here I guess I'd lose some time while the loading of the current page. (The view eats some ressources) but win time due to the efficiency of HQL (or am I wrong?).

3. A mixed solution of both. All the records have to be loaded into the cache in the beginning (again the question as mentioned above how they are really loaded - including the @OneToMany-Lists of its records) and the update is done with the HQL statement.

4. Something completely different?

Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate: When should I load my records?
 
Similar Threads
Hibernate keeps updating database.
Hibernate:Problem in updaing data to the database
Lazy-loading of collections generated by HQL ?
Delete cached data and load from database
How to pass Data from Hibernate query.list to the JSP Page