简体   繁体   中英

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? Or it's better to use only one of them?

EntityManageFactory is part of the JPA specification so it's more portable. SessionFactory is Hibernate specific but the implementation is a subclass of EntityManagerFactory anyway.

Using one or the other (or both) depends on the requirements, how you create the factory and which API you prefer. Hibernate will return an implementation that's compatible with both interfaces anyway.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM