-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate 3.6 Second Level caching
PostPosted: Mon Mar 18, 2013 10:33 am 
Newbie

Joined: Mon Mar 18, 2013 10:22 am
Posts: 1
Hi all,

I use an in memory datagrid (Coherence) as a second level cache (with hibernate 3.6 JPA)

I did a simple test on table Departments + Employees (Department load the collection of employees using Lazy loading, Employee load the department with the eager loading).

1) I did a "select * from departments"

In the log of hibernate I got

Hibernate: select department0_.DEPARTMENT_ID as DEPARTMENT1_1_, department0_.DEPARTMENT_NAME as DEPARTMENT2_1_ from DEPARTMENTS department0_
4.626: [GC [PSYoungGen: 131072K->10186K(152896K)] 131072K->10186K(502464K), 0.0181553 secs] [Times: user=0.08 sys=0.00, real=0.03 secs]
**********************************
Statistics For : model.Department
ElementCountInMemory : 28
ElementCountOnDisk : -1
Entries : {70={_version=null, _lazyPropertiesUnfetched=true, employees=70, _subclass=model.Department, name=Public Relations}, 200={_version=null, _lazyPropertiesUnfetched=true, employees=200, _subclass=model.Department, name=Operations}, 140={_version=null, _lazyPropertiesUnfetched=true, employees=140, _subclass=model.Department, name=Control And Credit}, 10={_version=null, _lazyPropertiesUnfetched=true, employees=10, _subclass=model.Department, name=Administration}, 400={_version=null, _lazyPropertiesUnfetched=true, employees=400, _subclass=model.Department, name=Stock}, 130={_version=null, _lazyPropertiesUnfetched=true, employees=130, _subclass=model.Department, name=Corporate Tax}, 220={_version=null, _lazyPropertiesUnfetched=true, employees=220, _subclass=model.Department, name=NOC}, 20={_version=null, _lazyPropertiesUnfetched=true, employees=20, _subclass=model.Department, name=Marketing}, 80={_version=null, _lazyPropertiesUnfetched=true, employees=80, _subclass=model.Department, name=Sales}, 260={_version=null, _lazyPropertiesUnfetched=true, employees=260, _subclass=model.Department, name=Recruiting}, 270={_version=null, _lazyPropertiesUnfetched=true, employees=270, _subclass=model.Department, name=Payroll}, 210={_version=null, _lazyPropertiesUnfetched=true, employees=210, _subclass=model.Department, name=IT Support}, 150={_version=null, _lazyPropertiesUnfetched=true, employees=150, _subclass=model.Department, name=Shareholder Services}, 30={_version=null, _lazyPropertiesUnfetched=true, employees=30, _subclass=model.Department, name=Purchasing}, 90={_version=null, _lazyPropertiesUnfetched=true, employees=90, _subclass=model.Department, name=Executive}, 170={_version=null, _lazyPropertiesUnfetched=true, employees=170, _subclass=model.Department, name=Manufacturing}, 100={_version=null, _lazyPropertiesUnfetched=true, employees=100, _subclass=model.Department, name=Finance}, 110={_version=null, _lazyPropertiesUnfetched=true, employees=110, _subclass=model.Department, name=Accounting}, 230={_version=null, _lazyPropertiesUnfetched=true, employees=230, _subclass=model.Department, name=IT Helpdesk}, 40={_version=null, _lazyPropertiesUnfetched=true, employees=40, _subclass=model.Department, name=Human Resources}, 160={_version=null, _lazyPropertiesUnfetched=true, employees=160, _subclass=model.Department, name=Benefits}, 50={_version=null, _lazyPropertiesUnfetched=true, employees=50, _subclass=model.Department, name=Shipping}, 250={_version=null, _lazyPropertiesUnfetched=true, employees=250, _subclass=model.Department, name=Retail Sales}, 190={_version=null, _lazyPropertiesUnfetched=true, employees=190, _subclass=model.Department, name=Contracting}, 240={_version=null, _lazyPropertiesUnfetched=true, employees=240, _subclass=model.Department, name=Government Sales}, 180={_version=null, _lazyPropertiesUnfetched=true, employees=180, _subclass=model.Department, name=Construction}, 120={_version=null, _lazyPropertiesUnfetched=true, employees=120, _subclass=model.Department, name=Treasury}, 60={_version=null, _lazyPropertiesUnfetched=true, employees=60, _subclass=model.Department, name=IT}}
HitCount : 0
MissCount : 0
PutCount : 28
SizeInMemory : -1
**********************************
**********************************
Statistics For : model.Employee
ElementCountInMemory : 0
ElementCountOnDisk : -1
Entries : {}
HitCount : 0
MissCount : 0
PutCount : 0
SizeInMemory : -1
**********************************
NB Dept : 28
**********************************

On Coherence Datagrid I saw 28 put --> OK but 56 get ? so why 2 get on each department here instead of 1 ?

2) I did a "select * from employees where employee_id = 100"

The log in hibernate

Hibernate: select employee0_.EMPLOYEE_ID as EMPLOYEE1_0_0_, employee0_.DEPARTMENT_ID as DEPARTMENT4_0_0_, employee0_.FIRST_NAME as FIRST2_0_0_, employee0_.LAST_NAME as LAST3_0_0_ from EMPLOYEES employee0_ where employee0_.EMPLOYEE_ID=?
4.356: [GC [PSYoungGen: 131072K->10608K(152896K)] 131072K->10608K(502464K), 0.0350694 secs] [Times: user=0.09 sys=0.02, real=0.05 secs]
**********************************
Statistics For : model.Department
ElementCountInMemory : 28
ElementCountOnDisk : -1
Entries : {70={_version=null, _lazyPropertiesUnfetched=true, employees=70, _subclass=model.Department, name=Public Relations}, 200={_version=null, _lazyPropertiesUnfetched=true, employees=200, _subclass=model.Department, name=Operations}, 140={_version=null, _lazyPropertiesUnfetched=true, employees=140, _subclass=model.Department, name=Control And Credit}, 10={_version=null, _lazyPropertiesUnfetched=true, employees=10, _subclass=model.Department, name=Administration}, 400={_version=null, _lazyPropertiesUnfetched=true, employees=400, _subclass=model.Department, name=Stock}, 130={_version=null, _lazyPropertiesUnfetched=true, employees=130, _subclass=model.Department, name=Corporate Tax}, 220={_version=null, _lazyPropertiesUnfetched=true, employees=220, _subclass=model.Department, name=NOC}, 20={_version=null, _lazyPropertiesUnfetched=true, employees=20, _subclass=model.Department, name=Marketing}, 80={_version=null, _lazyPropertiesUnfetched=true, employees=80, _subclass=model.Department, name=Sales}, 260={_version=null, _lazyPropertiesUnfetched=true, employees=260, _subclass=model.Department, name=Recruiting}, 270={_version=null, _lazyPropertiesUnfetched=true, employees=270, _subclass=model.Department, name=Payroll}, 210={_version=null, _lazyPropertiesUnfetched=true, employees=210, _subclass=model.Department, name=IT Support}, 150={_version=null, _lazyPropertiesUnfetched=true, employees=150, _subclass=model.Department, name=Shareholder Services}, 30={_version=null, _lazyPropertiesUnfetched=true, employees=30, _subclass=model.Department, name=Purchasing}, 90={_version=null, _lazyPropertiesUnfetched=true, employees=90, _subclass=model.Department, name=Executive}, 170={_version=null, _lazyPropertiesUnfetched=true, employees=170, _subclass=model.Department, name=Manufacturing}, 100={_version=null, _lazyPropertiesUnfetched=true, employees=100, _subclass=model.Department, name=Finance}, 110={_version=null, _lazyPropertiesUnfetched=true, employees=110, _subclass=model.Department, name=Accounting}, 230={_version=null, _lazyPropertiesUnfetched=true, employees=230, _subclass=model.Department, name=IT Helpdesk}, 40={_version=null, _lazyPropertiesUnfetched=true, employees=40, _subclass=model.Department, name=Human Resources}, 160={_version=null, _lazyPropertiesUnfetched=true, employees=160, _subclass=model.Department, name=Benefits}, 50={_version=null, _lazyPropertiesUnfetched=true, employees=50, _subclass=model.Department, name=Shipping}, 250={_version=null, _lazyPropertiesUnfetched=true, employees=250, _subclass=model.Department, name=Retail Sales}, 190={_version=null, _lazyPropertiesUnfetched=true, employees=190, _subclass=model.Department, name=Contracting}, 240={_version=null, _lazyPropertiesUnfetched=true, employees=240, _subclass=model.Department, name=Government Sales}, 180={_version=null, _lazyPropertiesUnfetched=true, employees=180, _subclass=model.Department, name=Construction}, 120={_version=null, _lazyPropertiesUnfetched=true, employees=120, _subclass=model.Department, name=Treasury}, 60={_version=null, _lazyPropertiesUnfetched=true, employees=60, _subclass=model.Department, name=IT}}
HitCount : 1
MissCount : 0
PutCount : 0
SizeInMemory : -1
**********************************
**********************************
Statistics For : model.Employee
ElementCountInMemory : 1
ElementCountOnDisk : -1
Entries : {100={lastname=King, _version=null, _lazyPropertiesUnfetched=true, firstname=Steven, department=90, _subclass=model.Employee}}
HitCount : 0
MissCount : 1
PutCount : 1
SizeInMemory : -1
**********************************
Employee [id=100, firstname=Steven, lastname=King, department Id=90]

Nice I have a hit on the department !!!

But in Coherence I saw :

On employee : 1 put (OK) but 3 get ? why 3 instead of 1 ?

On department : 0 put (OK) but 29 (28 + 1) get ? why not just 1 ?

Thank you for all...

PB


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.