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



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

Answer / 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

More Advanced Java Interview Questions

why static class in java

0 Answers   Infotech, SunGard,


For an example, if we have some variable in run method, and we created one or more threads. Does all threads will share the same variable or a copy of variable is created for each thread??

1 Answers  


What classes of exceptions may be caught by a catch clause?

0 Answers  


what is catalina in tomcat server.

11 Answers   IBM,


What is re-entrant. Is session beans reentrant. Is entity beans reentrant?

0 Answers  






What is the difference between a menuitem and a checkboxmenuitem?

0 Answers  


Can I import same package/class twice? Will the jvm load the package twice at runtime?

0 Answers  


how do you Handle Front End Application data against DB with example?

0 Answers   Campus Interaction, HCL,


When is the best time to validate input?

0 Answers  


Thread life cycle?

3 Answers   TCS,


What is the purpose of the finally clause of a try-catch-finally statement?

0 Answers  


Urgent Openings for Java and .NET ( India, Singapore, Australia, Japan)

2 Answers   Wipro,


Categories