Give me simple example of hibernate caching and explain the
details of caching????? thanks in adv.

Answer Posted / imambasha

caching concept in hibernate is performed internally in
stages...
1)firstlevel(Session) caching
2)Secondlevel(SessionFactory) caching
1)firstlevel(Session) caching:
First-level cache always Associates with the Session
object. Hibernate uses this cache by default. Here, it
processes one transaction after another one, means wont
process one transaction many times. Mainly it reduces the
number of SQL queries it needs to generate within a given
transaction. That is instead of updating after every
modification done in the transaction, it updates the
transaction only at the end of the transaction.

2)Secondlevel(SessionFactory) caching
Second-level cache always associates with the Session
Factory object. While running the transactions, in between
it loads the objects at the Session Factory level, so that
those objects will available to the entire application,
don’t bounds to single user. Since the objects are already
loaded in the cache, whenever an object is returned by the
query, at that time no need to go for a database
transaction. In this way the second level cache works.

Is This Answer Correct ?    11 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is TL and its use?

1996


Difference between DurableSubscription and non- DurableSubscription?

1720


Difference between loadclass and class.forname?

602


What is bean? Where can it be used?

585


Explain the difference between object state and behavior?

572






What is message driven beam?

585


AS a developer will u create a data source in connection pool? If so how will u do that, how to access the object from connection pool using IRAD tool?

1649


What is the diffrence between a local-tx-datasource and a xa-datasource?

582


What is prototype?

613


whats is mean by connectionpooling

1571


Is the ternary operator written x : y ? Z or x ? Y : z ?

641


how i secure my site with the https protocol.what are the steps?

1741


When is the best time to validate input?

613


What is the difference between system.out ,system.err and system.in?

602


What is table mutation and how do you avoid it?

1921