Ok ! ;)
I'm new to second level caching and thought I would get it easily... obviously not !
Any good resource you could advise me to read beyond hibernate documentation ?
EDIT :
Ok.
I tried
getSessionFactory().getStatistics()
.getSecondLevelCacheStatistics("system.model.entities.Item")
.getEntries());
before and after a first call proved me that obviously, the cache was filled with objects returned by query.
So objects are put to the cache.
Something I didn't get is that, after having set the logging level to "debug",
it's OBVIOUS that hibernate make some SQL call.
FIRST CALL :
2006-06-12 15:02:02,453 DEBUG org.hibernate.jdbc.ConnectionManager - opening JDBC connection
2006-06-12 15:02:02,453 DEBUG org.hibernate.SQL - select this_.id as id1_0_, this_1_.name as name1_0_, this_1_.descrip
tion as descript3_1_0_ from SimpleItem this_ inner join Item this_1_ on this_.id=this_1_.id
Hibernate: select this_.id as id1_0_, this_1_.name as name1_0_, this_1_.description as descript3_1_0_ from SimpleItem th
is_ inner join Item this_1_ on this_.id=this_1_.id
2006-06-12 15:02:02,453 DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
2006-06-12 15:02:02,468 DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, global
ly: 0)
2006-06-12 15:02:02,468 DEBUG org.hibernate.loader.Loader - processing result set
2006-06-12 15:02:02,468 DEBUG org.hibernate.loader.Loader - result set row: 0
2006-06-12 15:02:02,468 DEBUG org.hibernate.type.LongType - returning '1' as column: id1_0_
SECOND :
2006-06-12 15:02:45,890 DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedState
ments: 0, globally: 0)
2006-06-12 15:02:45,890 DEBUG org.hibernate.jdbc.ConnectionManager - opening JDBC connection
2006-06-12 15:02:45,890 DEBUG org.hibernate.SQL - select this_.id as id1_0_, this_1_.name as name1_0_, this_1_.descrip
tion as descript3_1_0_ from SimpleItem this_ inner join Item this_1_ on this_.id=this_1_.id
Hibernate: select this_.id as id1_0_, this_1_.name as name1_0_, this_1_.description as descript3_1_0_ from SimpleItem th
is_ inner join Item this_1_ on this_.id=this_1_.id
2006-06-12 15:02:45,890 DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
2006-06-12 15:02:45,890 DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, global
ly: 0)
2006-06-12 15:02:45,890 DEBUG org.hibernate.loader.Loader - processing result set
2006-06-12 15:02:45,890 DEBUG org.hibernate.loader.Loader - result set row: 0
2006-06-12 15:02:45,890 DEBUG org.hibernate.type.LongType - returning '1' as column: id1_0_
So what is the probleme here ?
I re-read a part of a book on Hibernate 3 (in french) and it was clearly saying that there will be no sql invovled in a second call if cache is enabled (in the case of a READ-ONLY cached entity)...
Am I missing something ?
Thank you for your time,
Seb.
|