Hibernate SessionFactory与JPA EntityManagerFactory [英] Hibernate SessionFactory vs. JPA EntityManagerFactory

查看:191
本文介绍了Hibernate SessionFactory与JPA EntityManagerFactory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Hibernate的新手,我不确定是否要使用Hibernate SessionFactory或JPA EntityManagerFactory创建Hibernate Session.

I am new to Hibernate and I'm not sure whether to use a Hibernate SessionFactory or a JPA EntityManagerFactory to create a Hibernate Session.

这两者之间有什么区别?有什么优点和优点?使用这些功能的弊端?

What is the difference between these two? What are the pros & cons of using each of those?

推荐答案

首选EntityManagerFactoryEntityManager.它们是由JPA标准定义的.

Prefer EntityManagerFactory and EntityManager. They are defined by the JPA standard.

SessionFactorySession是休眠专用的. EntityManager在后台调用休眠会话.而且,如果您需要EntityManager中不可用的某些特定功能,则可以通过调用以下内容来获得会话:

SessionFactory and Session are hibernate-specific. The EntityManager invokes the hibernate session under the hood. And if you need some specific features that are not available in the EntityManager, you can obtain the session by calling:

Session session = entityManager.unwrap(Session.class);

这篇关于Hibernate SessionFactory与JPA EntityManagerFactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆