-->
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.  [ 5 posts ] 
Author Message
 Post subject: Need to understand cacheing and what is stored in cache ?
PostPosted: Mon Feb 09, 2004 11:21 am 
Beginner
Beginner

Joined: Tue Feb 03, 2004 4:53 pm
Posts: 28
I am trying to validate the following --
1) when one calls session.load(class,serializable) does hibernate check its cache for the existence of a preparedStatement for the load process or does it create a new sql string for each load ?
2) Is there a way to force Hibernate to create preparedStatements for each <mapping> and cache the preparedStatement -- for each state change -- load,update,delete,create ? --DBA's would love this.
3) does the cache lifecycle exist with-in a session's life cycle or sessionFactries lifecycle ?


I am new to this so please be kind..


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 09, 2004 11:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Prepared Statement caching is the job of the database pool. Both c3po and dbcp do this. So if you configure your pool accordingly, all executed queries will be prepared statment cached, because Hibernate uses prepared statements everywhere. Hibernate will still cache generated SQL, to avoid SQL generation overhead.

Hibernate has a two-level-cache structure, the Session level cache allways exists, and you may optionally use an additional jvm-level cache (EHCache, SwarmCache ...)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 09, 2004 11:42 am 
Beginner
Beginner

Joined: Tue Feb 03, 2004 4:53 pm
Posts: 28
gloeglm: does Hibernate cache a java.sql.PreparedStatement or just the String representation of the PreparedStatement ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 09, 2004 11:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
As I said, Hibernate does not cache any PreparedStatements at all, the DB-Pool should cache the PreparedStatements. (Both c3po and dbcp do).

Hibernate does cache the generated SQL strings, to avoid the overhead of repeated SQL generation. Multiple requests to createStatement() with the same SQL string results in the same prepared statement when the pool does prepared statement caching.

So basically when you use a proper pool (not the Hibernate builtin one!), every SQL will be generated only once, and the prepared statement for it will be generated only once, too.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 09, 2004 11:54 am 
Beginner
Beginner

Joined: Tue Feb 03, 2004 4:53 pm
Posts: 28
Thank you very much -- I will dig into C3P0 --


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