-->
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.  [ 2 posts ] 
Author Message
 Post subject: Cashing in Hibernate
PostPosted: Wed Jan 12, 2005 3:24 am 
Beginner
Beginner

Joined: Tue Dec 21, 2004 3:18 am
Posts: 32
Hi All,
I've been trying to use caching in hibernate but while working I realized some points and I need some explanation for them , if anyone could help.
1- when I used caching in the hibernate mapping files
i.e: <cache usage="read-write"/>
and after tracing the log of mysql, I found that it executed two similar queries which are:
select customer0_.cid as cid, customer0_.name as name, customer0_.address as address, customer0_.tel as tel from customer customer0_ where (customer0_.name='c2' )and(customer0_.address='c2add' )

2- When I used : query.setCacheable(true) , it executed two different queries which are:
select customer0_.cid as cid, customer0_.name as name, customer0_.address as address, customer0_.tel as tel from customer customer0_ where (customer0_.name='c2' )and(customer0_.address='c2add' )

and

select customer0_.cid as cid0_, customer0_.name as name0_, customer0_.address as address0_, customer0_.tel as tel0_ from customer customer0_ where customer0_.cid=3

3- When I used both : <cache usage="read-write"/> and query.setCacheable(true) , it executed only one query.

Could anyone please explain the differences between the three cases specially the second one.

Thanks in Advance.
Sherihan.


Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 12, 2005 7:29 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
The first one cache the instances by their ids
The second one cache the ids of the entities returned by a query

_________________
Emmanuel


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