开发者

Will hibernate cache (EHCache for eg) will work with jpa specific code (if I use EntityManager/EM Factory instead of Session/SessionFactory)?

I have very simple query. I want to make sure that I don't have any confusion. I saw in the spec that caching is not a part of spec and is provided according to specific orm tool providers. I'm using Hibernate as an ORM tool in my application. But to be vendor independent I'm using everything (annotations, classes, etc) of JPA (javax.persistence) and not anything specifically provided by Hibernate. I'm using EntityManager and EntityManagerFactory instead of SessionFactory and Session. My query is that in the blogs I saw that cache providers and caching mechanism provided by Hibernate is taken care of by Session (indirectly). So is it possible that EntityManager will also be able to use to cache providers and cache configuration开发者_如何学Python and hence the entities and queries specified as cacheable will be able to use the caching features? (I think they should be). Also is there any api provided by JPA (like Statistics api provided by Hibernate) to measure and view caching statistics? Please help me in this regards.


Yes, it will work just fine. If you look at the code, EntityManagerImpl delegates to a SessionImpl, so everything will work as with pure hibernate. Also check this article about caching in JPA 2.0

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜