"[EMAIL PROTECTED]" wrote : So here's my understand how Hibernate uses the 2nd 
level cache (disclaimer: I'm not a Hibernate expert).
  | And I haven't read the docs yet...
  | 
  | - 1st level cache is per Session. This is an Object-level cache
  | - 2nd level is per VM, shared by all Sessions. This is a row-based cache
  | - When an object is loaded, the corresponding rows are loaded from the DB 
and added to the 2nd level cache. Assuming we use JBossCache, these will be 
replicated
  | (not sure about this point though)
  | 

Right. and this is the place where write to cache happens.

following hibernate log records show what happens while loading entity which is 
missed in cache:

anonymous wrote : 
  | 14:59:10,338 DEBUG [SessionImpl] loading [test.TestEntity#1]
  | 14:59:10,338 DEBUG [SessionImpl] attempting to resolve [test.TestEntity#1]
  | 14:59:10,416 DEBUG [SessionImpl] object not resolved in any cache 
[test.TestEntity#1]
  | 14:59:10,416 DEBUG [BatcherImpl] about to open: 0 open PreparedStatements, 
0 open ResultSets
  | 14:59:16,432 DEBUG [SQL] select testentity0_.id as id0_, testentity0_.value 
as value0_ from TEST_ENTITY testentity0_ where testentity0_.id=?
  | 14:59:16,432 DEBUG [BatcherImpl] preparing statement
  | 14:59:16,682 DEBUG [BatcherImpl] done closing: 0 open PreparedStatements, 0 
open ResultSets
  | 14:59:16,682 DEBUG [BatcherImpl] closing statement
  | 14:59:16,682 DEBUG [SessionImpl] resolving associations for 
[test.TestEntity#1]
  | 14:59:16,697 DEBUG [SessionImpl] adding entity to second-level cache 
[test.TestEntity#1]
  | 14:59:16,729 DEBUG [SessionImpl] done materializing entity 
[test.TestEntity#1]
  | 

as you see "adding entity to second-level cache" happens just after reading 
entity from storage and this is the place where cache.put() called.

"[EMAIL PROTECTED]" wrote : 
  | So in your servlet code, if you only do load() methods, you should *never* 
run into lock acquisition problems.
  | 

In fact, doing only load() I do run into locking problem.


View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3863943#3863943

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3863943


-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
JBoss-Development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to