Default cache used by Hibernate?

后端 未结 2 1972
野趣味
野趣味 2021-02-06 09:26

What is the name of the default cache used by Hibernate? Is there a default cache even, or do you have to add a cache provider in order to take advantage of a cache?

I t

2条回答
  •  轮回少年
    2021-02-06 10:15

    Hibernate already provides a caching mechanisms called 1st level cache by the persistent context . It is in the Session scoped , enabled by default and cannot be turned off.

    The cache provider such as EHCache provides another caching mechanisms called 2nd level cache . It is in the SessionFactory scoped . No 2nd level cache is enable by default and you have to configure it .

    See this for how to enable EHCache in hibernate.

提交回复
热议问题