-->
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.  [ 4 posts ] 
Author Message
 Post subject: A comprehension question
PostPosted: Sun May 27, 2007 8:19 am 
Newbie

Joined: Fri Apr 27, 2007 5:05 pm
Posts: 7
Hi,
1) I have got a Class User who accessed by Hibernate.

2) I have now a method getUser() who gets a specific user from DB (with hibernate).

3) I have a jsp file which shows the users settings. I am accessing these settings via getUser().getXXX. The User has round about 20 settings.

Do I access the Database 20 times or does HIbernate caches my specific user and I have not worry about to use the getUser() method to fill the setting.jsp?

Thnx
Alex


Top
 Profile  
 
 Post subject: If configured correctly
PostPosted: Sun May 27, 2007 8:33 am 
Regular
Regular

Joined: Wed Aug 24, 2005 11:49 am
Posts: 63
I you use a session-in-view pattern and configure everything correctly, there will be 1 query executed on the db.
After that, your user object is in the 1st level cache.
That cache is available for 1 transaction (more or less).

For more info, see: http://hibernate.org/42.html

Edwin

_________________
Edwin van der Elst
Finalist IT Group


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 28, 2007 3:14 am 
Beginner
Beginner

Joined: Thu Mar 29, 2007 11:57 am
Posts: 27
Another fast and secure way to check how many database queries are sent to your db: Just have a look to your db logs or db monitor. Then you can retrace what happened exactly.
Regardt,
TMK


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 28, 2007 3:43 am 
Senior
Senior

Joined: Thu May 17, 2007 2:31 am
Posts: 194
Location: Sri Lanka
Hi

set show_sql=true to view all hibernate queries.

Amila

(Don't forget to rate if helps)


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