[英]Using EntityManagerFactory and SessionFactory together at the same app for same database
Is it bad practice to use EntityManagerFactory and SessionFactory together at the same app for same database?在同一个应用程序中为同一个数据库同时使用 EntityManagerFactory 和 SessionFactory 是不好的做法吗? Or it's better to use only one of them?
或者最好只使用其中一个?
EntityManageFactory
is part of the JPA specification so it's more portable. EntityManageFactory
是 JPA 规范的一部分,因此它更具可移植性。 SessionFactory
is Hibernate specific but the implementation is a subclass of EntityManagerFactory
anyway. SessionFactory
是特定于 Hibernate 的,但无论如何实现都是EntityManagerFactory
的子类。
Using one or the other (or both) depends on the requirements, how you create the factory and which API you prefer.使用其中一个(或两者)取决于要求、创建工厂的方式以及您喜欢哪种 API。 Hibernate will return an implementation that's compatible with both interfaces anyway.
无论如何,Hibernate 将返回一个与这两个接口兼容的实现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.