Package net.officefloor.jpa
Class JpaManagedObjectSource
- java.lang.Object
-
- net.officefloor.frame.api.managedobject.source.impl.AbstractAsyncManagedObjectSource<O,F>
-
- net.officefloor.frame.api.managedobject.source.impl.AbstractManagedObjectSource<Indexed,None>
-
- net.officefloor.jpa.JpaManagedObjectSource
-
- All Implemented Interfaces:
ManagedObjectSource<Indexed,None>
- Direct Known Subclasses:
DataNucleusJpaManagedObjectSource,HibernateJpaManagedObjectSource
public class JpaManagedObjectSource extends AbstractManagedObjectSource<Indexed,None>
JPAManagedObjectSource.- Author:
- Daniel Sagenschneider
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJpaManagedObjectSource.DependencyTypeDependency type.static interfaceJpaManagedObjectSource.EntityManagerWrapperWraps theEntityManager.static interfaceJpaManagedObjectSource.EntityManagerWrapperFactoryFactory creating theEntityManagerwrapper.classJpaManagedObjectSource.JpaManagedObjectJPAManagedObject.static interfaceJpaManagedObjectSource.PersistenceFactoryFunctionalInterfaceto create theEntityManagerFactory.-
Nested classes/interfaces inherited from class net.officefloor.frame.api.managedobject.source.impl.AbstractAsyncManagedObjectSource
AbstractAsyncManagedObjectSource.DependencyLabeller<K extends java.lang.Enum<K>>, AbstractAsyncManagedObjectSource.ExecutionLabeller, AbstractAsyncManagedObjectSource.Labeller<K extends java.lang.Enum<K>>, AbstractAsyncManagedObjectSource.MetaDataContext<O extends java.lang.Enum<O>,F extends java.lang.Enum<F>>, AbstractAsyncManagedObjectSource.SpecificationContext
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringPROPERTY_DEPENDENCY_TYPEPropertyto specify the dependency type for theEntityManager.static java.lang.StringPROPERTY_PERSISTENCE_FACTORYstatic java.lang.StringPROPERTY_PERSISTENCE_UNITPropertyfor the name of the persistence unit.
-
Constructor Summary
Constructors Constructor Description JpaManagedObjectSource()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidbeginTransaction(javax.persistence.EntityManager entityManager)Begins the transaction on theEntityManager.static voidcommitTransaction(javax.persistence.EntityManager entityManager)Commits the transaction on theEntityManager.java.sql.ConnectiongetConnection()Obtains theConnection.protected ManagedObjectgetManagedObject()Synchronously obtains theManagedObject.protected JpaManagedObjectSource.PersistenceFactorygetPersistenceFactory(SourceContext context)Obtains theJpaManagedObjectSource.PersistenceFactory.protected booleanisRunWithinTransaction()Indicates if required to run withinEntityTransaction.protected voidloadMetaData(AbstractAsyncManagedObjectSource.MetaDataContext<Indexed,None> context)Overridden to load meta-data.protected voidloadSpecification(AbstractAsyncManagedObjectSource.SpecificationContext context)Overridden to load specifications.-
Methods inherited from class net.officefloor.frame.api.managedobject.source.impl.AbstractManagedObjectSource
sourceManagedObject
-
Methods inherited from class net.officefloor.frame.api.managedobject.source.impl.AbstractAsyncManagedObjectSource
getSpecification, init, start, stop
-
-
-
-
Field Detail
-
PROPERTY_DEPENDENCY_TYPE
public static final java.lang.String PROPERTY_DEPENDENCY_TYPE
Propertyto specify the dependency type for theEntityManager.- See Also:
- Constant Field Values
-
PROPERTY_PERSISTENCE_UNIT
public static final java.lang.String PROPERTY_PERSISTENCE_UNIT
Propertyfor the name of the persistence unit.- See Also:
- Constant Field Values
-
PROPERTY_PERSISTENCE_FACTORY
public static final java.lang.String PROPERTY_PERSISTENCE_FACTORY
- See Also:
- Constant Field Values
-
-
Method Detail
-
beginTransaction
public static void beginTransaction(javax.persistence.EntityManager entityManager)
Begins the transaction on the
EntityManager.As
OfficeFloormay manage the transaction for theEntityManager, it can not be begun. This enables beginning the transaction.- Parameters:
entityManager-EntityManager.
-
commitTransaction
public static void commitTransaction(javax.persistence.EntityManager entityManager)
Commits the transaction on the
EntityManager.As
OfficeFloormay manage the transaction for theEntityManager, it can not be committed. This enables committing the transaction.- Parameters:
entityManager-EntityManager.
-
getConnection
public java.sql.Connection getConnection()
Obtains theConnection.- Returns:
Connection.
-
getPersistenceFactory
protected JpaManagedObjectSource.PersistenceFactory getPersistenceFactory(SourceContext context) throws java.lang.Exception
Obtains the
JpaManagedObjectSource.PersistenceFactory.Specific vendor implementations may override this method to specify the
JpaManagedObjectSource.PersistenceFactory.By default, this method uses the
PROPERTY_PERSISTENCE_FACTORYPropertyto load theJpaManagedObjectSource.PersistenceFactory.- Parameters:
context-SourceContext.- Returns:
JpaManagedObjectSource.PersistenceFactory.- Throws:
java.lang.Exception- If fails to create theJpaManagedObjectSource.PersistenceFactory.
-
isRunWithinTransaction
protected boolean isRunWithinTransaction()
Indicates if required to run withinEntityTransaction.- Returns:
trueif required to run withinEntityTransaction.
-
loadSpecification
protected void loadSpecification(AbstractAsyncManagedObjectSource.SpecificationContext context)
Description copied from class:AbstractAsyncManagedObjectSourceOverridden to load specifications.- Specified by:
loadSpecificationin classAbstractAsyncManagedObjectSource<Indexed,None>- Parameters:
context- Specifications.
-
loadMetaData
protected void loadMetaData(AbstractAsyncManagedObjectSource.MetaDataContext<Indexed,None> context) throws java.lang.Exception
Description copied from class:AbstractAsyncManagedObjectSourceOverridden to load meta-data.- Specified by:
loadMetaDatain classAbstractAsyncManagedObjectSource<Indexed,None>- Parameters:
context- Meta-data.- Throws:
java.lang.Exception- If fails to load the meta-data.
-
getManagedObject
protected ManagedObject getManagedObject() throws java.lang.Throwable
Description copied from class:AbstractManagedObjectSourceSynchronously obtains theManagedObject.- Specified by:
getManagedObjectin classAbstractManagedObjectSource<Indexed,None>- Returns:
ManagedObject.- Throws:
java.lang.Throwable- If fails to obtain theManagedObject.
-
-