KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > ejb > EntityManagerFactoryImpl


1 //$Id: EntityManagerFactoryImpl.java,v 1.8 2005/07/21 00:08:34 epbernard Exp $
2
package org.hibernate.ejb;
3
4 import javax.persistence.EntityManager;
5 import javax.persistence.PersistenceContextType;
6
7 import org.hibernate.SessionFactory;
8 import org.hibernate.ejb.callback.EntityCallbackHandler;
9
10 /**
11  * @author Gavin King
12  */

13 public class EntityManagerFactoryImpl implements HibernateEntityManagerFactory {
14
15     private SessionFactory sessionFactory;
16
17     public EntityManagerFactoryImpl(SessionFactory sessionFactory) {
18         this.sessionFactory = sessionFactory;
19     }
20
21     public EntityManager createEntityManager() {
22         return createEntityManager( PersistenceContextType.TRANSACTION );
23     }
24
25     public EntityManager createEntityManager(PersistenceContextType type) {
26         return new EntityManagerImpl( sessionFactory, type );
27     }
28
29     public EntityManager getEntityManager() {
30         return new CurrentEntityManagerImpl( sessionFactory );
31     }
32
33     public void close() {
34         sessionFactory.close();
35     }
36
37     public boolean isOpen() {
38         return ! sessionFactory.isClosed();
39     }
40
41     public SessionFactory getSessionFactory() {
42         return sessionFactory;
43     }
44
45 }
46
Popular Tags