Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package java_hibernate.java_hibernate;
- import javax.persistence.EntityManager;
- import javax.persistence.EntityManagerFactory;
- import javax.persistence.Persistence;
- public class HibernateUtil {
- public static EntityManagerFactory factory = null;
- static {
- init();
- }
- private static void init() {
- try {
- if(factory == null) {
- factory = Persistence.createEntityManagerFactory("java-hibernate");
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public static EntityManager getEntityManager() {
- return factory.createEntityManager(); /* Provê persistência*/
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement