Hibernate Tutorial 33 - Configuring Second Level Cache

preview_player
Показать описание
We'll configure EHCache as our second level cache, and then put it to work. We'll fetch an object across two sessions, and we'll see how Hibernate's second level cache comes into play to save a database query.
Рекомендации по теме
Комментарии
Автор

Hoto & papaRamik got it right down below. If you are using Hibernate 4 then do the following:
1. include the jars in in your Hibernate User Library
2. modify the code of your hibernate.cfg.xml to look like the following:
<!-- Control the second-level cache  -->
        <property
        <property

good luck to all who are going through the tutorials!
And thank you Mr. Kothagal for the excellent tutorials. I appreciate how you frequently summarize and review what you have gone over in the video. I plan to use that strategy in my future YouTube channel. Thank you.

KentOJohnson
Автор

you are so clear about your concepts about each topic! It reflects through your teaching crystal clear! THANK YOU!

priyankawagh
Автор

A thousand thank yous to you. I have been searching for a solution for this for about two hours and then I looked here. Thank you. :)

LeBadman
Автор

Nice tutorial! I love straight to the point articles with example code.

kumarabhishek
Автор

Thank you for this video. We look forward to more videos in the near future.

recoveringheart
Автор

Thank you so much koushik, you are brilliant at what you do.

mateuszalmannai
Автор

Dear koushik,

Thanks for Weldon Job, I salute to your teaching strategy :)

Thanks,
Krishna

kpsingh
Автор

Excellent set of tutorials.
How can we thank you enough for them?

hyperborean
Автор

I'm trying to get this to work with Hibernate-release-4.3, 7.Final and it will not work no matter what the heck I try.
There is no ehcache class in it at all.
This is so frustrating and is stopping me from finishing the tutorials.
I'm so annoyed everything was going fine up to this.
Now I'm completely stuck.

Ok got it fixed now.
What Kent Johnson said fixed it and it worked straight away.
Thanks Kent Johnson.

quinnd
Автор

Very nice and clear tutorial. Thank you.

kamilkooo
Автор

Thanks a lot Kaushik for your tutorials!!!

ashutoshsharma
Автор

Brillient job u have done dear thanks a lot :)

AmuSharma
Автор

thanks, very helpful
for others:
now there is no need to downlaod EhCache.tar
everything is in
just add all the jars in there and paste that property what papaRomik included

SoeaOu
Автор

Very informative video. I have a confusion with hibernate second-level cache. Suppose our second-level cache has some data and our application fire one JDBC SQL query to fetch this data( which 2nd level cache already have) ...now 2nd level cache will return this data to the application without making any call to DB. Now my confusion is how 2nd level cache having the capability to understand JDBC SQL query to respond back to the application. I am not considering the query-cache concept at this moment.

vivekmit
Автор

Hi,
I am using Hibernate 4.2.6 and done the steps you have mentioned but I am getting below error. I haven't downloaded the EHCache jar separately as it's alreadypresent in lib/optional/ehcache folder. I have included all the jars present in this folder. I see that error message gives package name as org/hibernate/cache .. this seems to be the old package .. any idea why this error is coming?

Exception in thread "main"

nehaagrawal
Автор

I had a problem of configuration:
"Exception in thread "main" Second-level cache is not enabled for usage ..."

papaRomik
Автор

is this cache.use_second_level_cache property really necessary? Because I tried without it and the second level cache still works

albalupa
Автор

for hibernate 5.3.15:
add below dependencies in pom .xml:
<dependency>


<version>3.8.1</version>
</dependency>
<dependency>



</dependency>
<dependency>



</dependency>
add below configuration:
<property
<property
<property

suryanshanand
Автор

Nice explanation. when i used second level cache to fetch same object from different session it fired only one select query and it also gave me similar object but they were not same object. syso(obj1==obj2) returns 'false'. Does second level cache clone the object?

radiant_rhea
Автор

I followed the same steps that you said for configuring the second level cache and when I tested it out I get the following exception:

Exception in thread "main" This TransactionCoordinator has been closed

1.Used Hibernate 4.3.0 alpha1 release
2. Configuration contains:
property

property

ppuja