org.apache.openjpa.persistence
Class EntityManagerFactoryImpl

java.lang.Object
  extended by org.apache.openjpa.persistence.EntityManagerFactoryImpl
All Implemented Interfaces:
Serializable, EntityManagerFactory, PersistenceUnitUtil, PersistenceUtil, Closeable, OpenJPAEntityManagerFactory, OpenJPAEntityManagerFactorySPI

public class EntityManagerFactoryImpl
extends Object
implements OpenJPAEntityManagerFactory, OpenJPAEntityManagerFactorySPI, Closeable, PersistenceUnitUtil

Implementation of EntityManagerFactory that acts as a facade to a BrokerFactory.

Author:
Marc Prud'hommeaux
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.apache.openjpa.persistence.OpenJPAEntityManagerFactory
CONN_RETAIN_ALWAYS, CONN_RETAIN_DEMAND, CONN_RETAIN_TRANS
 
Constructor Summary
EntityManagerFactoryImpl()
          Default constructor provided for auto-instantiation.
EntityManagerFactoryImpl(BrokerFactory factory)
          Supply delegate on construction.
 
Method Summary
 void addLifecycleListener(Object listener, Class... classes)
          Register a listener for lifecycle-related events on the specified classes.
 void addTransactionListener(Object listener)
          Register a listener for transaction-related events on the specified classes.
 void close()
           
 OpenJPAEntityManagerSPI createEntityManager()
           
 OpenJPAEntityManagerSPI createEntityManager(Map props)
          Creates and configures a entity manager with the given properties.
 boolean equals(Object other)
           
 BrokerFactory getBrokerFactory()
          Delegate.
 Cache getCache()
           
 OpenJPAConfiguration getConfiguration()
          Return the configuration for this factory.
 OpenJPACriteriaBuilder getCriteriaBuilder()
          Gets the QueryBuilder with OpenJPA-extended capabilities.
 OpenJPAQueryBuilder getDynamicQueryBuilder()
          Gets a builder for dynamic queries.
 Object getIdentifier(Object entity)
          Get the identifier for the specified entity.
 MetamodelImpl getMetamodel()
           
 PersistenceUnitUtil getPersistenceUnitUtil()
           
 Map<String,Object> getProperties()
          Return properties describing this runtime.
 QueryResultCache getQueryResultCache()
          Access query result cache.
 StoreCache getStoreCache()
          Access the level 2 store cache.
 StoreCache getStoreCache(String cacheName)
          Access a named level 2 store cache.
 Set<String> getSupportedProperties()
          Get the properties supported by this runtime.
 Object getUserObject(Object key)
          Get the value for the specified key from the map of user objects.
 int hashCode()
           
 boolean isLoaded(Object entity)
           
 boolean isLoaded(Object entity, String attribute)
           
 boolean isOpen()
           
protected  EntityManagerImpl newEntityManagerImpl(Broker broker)
          Create a new entity manager around the given broker.
 Object putUserObject(Object key, Object val)
          Put the specified key-value pair into the map of user objects.
 void removeLifecycleListener(Object listener)
          Remove a listener for lifecycle-related events.
 void removeTransactionListener(Object listener)
          Remove a listener for transaction-related events.
 void setBrokerFactory(BrokerFactory factory)
          Delegate must be provided before use.
(package private)  FetchPlan toFetchPlan(Broker broker, FetchConfiguration fetch)
          Create a store-specific facade for the given fetch configuration.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EntityManagerFactoryImpl

public EntityManagerFactoryImpl()
Default constructor provided for auto-instantiation.


EntityManagerFactoryImpl

public EntityManagerFactoryImpl(BrokerFactory factory)
Supply delegate on construction.

Method Detail

getBrokerFactory

public BrokerFactory getBrokerFactory()
Delegate.


setBrokerFactory

public void setBrokerFactory(BrokerFactory factory)
Delegate must be provided before use.


getConfiguration

public OpenJPAConfiguration getConfiguration()
Description copied from interface: OpenJPAEntityManagerFactorySPI
Return the configuration for this factory.

Specified by:
getConfiguration in interface OpenJPAEntityManagerFactory
Specified by:
getConfiguration in interface OpenJPAEntityManagerFactorySPI

getProperties

public Map<String,Object> getProperties()
Description copied from interface: OpenJPAEntityManagerFactory
Return properties describing this runtime.

Specified by:
getProperties in interface EntityManagerFactory
Specified by:
getProperties in interface OpenJPAEntityManagerFactory

putUserObject

public Object putUserObject(Object key,
                            Object val)
Description copied from interface: OpenJPAEntityManagerFactory
Put the specified key-value pair into the map of user objects.

Specified by:
putUserObject in interface OpenJPAEntityManagerFactory

getUserObject

public Object getUserObject(Object key)
Description copied from interface: OpenJPAEntityManagerFactory
Get the value for the specified key from the map of user objects.

Specified by:
getUserObject in interface OpenJPAEntityManagerFactory

getStoreCache

public StoreCache getStoreCache()
Description copied from interface: OpenJPAEntityManagerFactory
Access the level 2 store cache. This cache acts as a proxy to all named caches.

Specified by:
getStoreCache in interface OpenJPAEntityManagerFactory

getStoreCache

public StoreCache getStoreCache(String cacheName)
Description copied from interface: OpenJPAEntityManagerFactory
Access a named level 2 store cache.

Specified by:
getStoreCache in interface OpenJPAEntityManagerFactory

getQueryResultCache

public QueryResultCache getQueryResultCache()
Description copied from interface: OpenJPAEntityManagerFactory
Access query result cache.

Specified by:
getQueryResultCache in interface OpenJPAEntityManagerFactory

createEntityManager

public OpenJPAEntityManagerSPI createEntityManager()
Specified by:
createEntityManager in interface EntityManagerFactory
Specified by:
createEntityManager in interface OpenJPAEntityManagerFactory
Specified by:
createEntityManager in interface OpenJPAEntityManagerFactorySPI

createEntityManager

public OpenJPAEntityManagerSPI createEntityManager(Map props)
Creates and configures a entity manager with the given properties. The property keys in the given map can be either qualified or not.

Specified by:
createEntityManager in interface EntityManagerFactory
Specified by:
createEntityManager in interface OpenJPAEntityManagerFactory
Specified by:
createEntityManager in interface OpenJPAEntityManagerFactorySPI
Returns:
list of exceptions raised or empty list.

newEntityManagerImpl

protected EntityManagerImpl newEntityManagerImpl(Broker broker)
Create a new entity manager around the given broker.


addLifecycleListener

public void addLifecycleListener(Object listener,
                                 Class... classes)
Description copied from interface: OpenJPAEntityManagerFactorySPI
Register a listener for lifecycle-related events on the specified classes. If the classes are null, all events will be propagated to the listener. The listener will be passed on to all new entity managers. See the org.apache.openjpa.event package for listener types.

Specified by:
addLifecycleListener in interface OpenJPAEntityManagerFactory
Specified by:
addLifecycleListener in interface OpenJPAEntityManagerFactorySPI

removeLifecycleListener

public void removeLifecycleListener(Object listener)
Description copied from interface: OpenJPAEntityManagerFactorySPI
Remove a listener for lifecycle-related events.

Specified by:
removeLifecycleListener in interface OpenJPAEntityManagerFactory
Specified by:
removeLifecycleListener in interface OpenJPAEntityManagerFactorySPI

addTransactionListener

public void addTransactionListener(Object listener)
Description copied from interface: OpenJPAEntityManagerFactorySPI
Register a listener for transaction-related events on the specified classes. The listener will be passed on to all new entity managers. See the org.apache.openjpa.event package for listener types.

Specified by:
addTransactionListener in interface OpenJPAEntityManagerFactory
Specified by:
addTransactionListener in interface OpenJPAEntityManagerFactorySPI

removeTransactionListener

public void removeTransactionListener(Object listener)
Description copied from interface: OpenJPAEntityManagerFactorySPI
Remove a listener for transaction-related events.

Specified by:
removeTransactionListener in interface OpenJPAEntityManagerFactory
Specified by:
removeTransactionListener in interface OpenJPAEntityManagerFactorySPI

close

public void close()
Specified by:
close in interface EntityManagerFactory
Specified by:
close in interface Closeable

isOpen

public boolean isOpen()
Specified by:
isOpen in interface EntityManagerFactory

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Overrides:
equals in class Object

toFetchPlan

FetchPlan toFetchPlan(Broker broker,
                      FetchConfiguration fetch)
Create a store-specific facade for the given fetch configuration. If no facade class exists, we use the default FetchPlan.


getCache

public Cache getCache()
Specified by:
getCache in interface EntityManagerFactory

getCriteriaBuilder

public OpenJPACriteriaBuilder getCriteriaBuilder()
Description copied from interface: OpenJPAEntityManagerFactory
Gets the QueryBuilder with OpenJPA-extended capabilities.

Specified by:
getCriteriaBuilder in interface EntityManagerFactory
Specified by:
getCriteriaBuilder in interface OpenJPAEntityManagerFactory

getDynamicQueryBuilder

public OpenJPAQueryBuilder getDynamicQueryBuilder()
Description copied from interface: OpenJPAEntityManagerFactory
Gets a builder for dynamic queries.

Specified by:
getDynamicQueryBuilder in interface OpenJPAEntityManagerFactory

getSupportedProperties

public Set<String> getSupportedProperties()
Description copied from interface: OpenJPAEntityManagerFactory
Get the properties supported by this runtime.

Specified by:
getSupportedProperties in interface OpenJPAEntityManagerFactory

getMetamodel

public MetamodelImpl getMetamodel()
Specified by:
getMetamodel in interface EntityManagerFactory

getPersistenceUnitUtil

public PersistenceUnitUtil getPersistenceUnitUtil()
Specified by:
getPersistenceUnitUtil in interface EntityManagerFactory

getIdentifier

public Object getIdentifier(Object entity)
Get the identifier for the specified entity. If not managed by any of the em's in this PU or not persistence capable, return null.

Specified by:
getIdentifier in interface PersistenceUnitUtil

isLoaded

public boolean isLoaded(Object entity)
Specified by:
isLoaded in interface PersistenceUnitUtil
Specified by:
isLoaded in interface PersistenceUtil

isLoaded

public boolean isLoaded(Object entity,
                        String attribute)
Specified by:
isLoaded in interface PersistenceUnitUtil
Specified by:
isLoaded in interface PersistenceUtil


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.