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:
|