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 class
JpaManagedObjectSource.DependencyType
Dependency type.static interface
JpaManagedObjectSource.EntityManagerWrapper
Wraps theEntityManager
.static interface
JpaManagedObjectSource.EntityManagerWrapperFactory
Factory creating theEntityManager
wrapper.class
JpaManagedObjectSource.JpaManagedObject
JPAManagedObject
.static interface
JpaManagedObjectSource.PersistenceFactory
FunctionalInterface
to 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.String
PROPERTY_DEPENDENCY_TYPE
Property
to specify the dependency type for theEntityManager
.static java.lang.String
PROPERTY_PERSISTENCE_FACTORY
static java.lang.String
PROPERTY_PERSISTENCE_UNIT
Property
for 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 void
beginTransaction(javax.persistence.EntityManager entityManager)
Begins the transaction on theEntityManager
.static void
commitTransaction(javax.persistence.EntityManager entityManager)
Commits the transaction on theEntityManager
.java.sql.Connection
getConnection()
Obtains theConnection
.protected ManagedObject
getManagedObject()
Synchronously obtains theManagedObject
.protected JpaManagedObjectSource.PersistenceFactory
getPersistenceFactory(SourceContext context)
Obtains theJpaManagedObjectSource.PersistenceFactory
.protected boolean
isRunWithinTransaction()
Indicates if required to run withinEntityTransaction
.protected void
loadMetaData(AbstractAsyncManagedObjectSource.MetaDataContext<Indexed,None> context)
Overridden to load meta-data.protected void
loadSpecification(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
Property
to specify the dependency type for theEntityManager
.- See Also:
- Constant Field Values
-
PROPERTY_PERSISTENCE_UNIT
public static final java.lang.String PROPERTY_PERSISTENCE_UNIT
Property
for 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
OfficeFloor
may 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
OfficeFloor
may 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_FACTORY
Property
to 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:
true
if required to run withinEntityTransaction
.
-
loadSpecification
protected void loadSpecification(AbstractAsyncManagedObjectSource.SpecificationContext context)
Description copied from class:AbstractAsyncManagedObjectSource
Overridden to load specifications.- Specified by:
loadSpecification
in classAbstractAsyncManagedObjectSource<Indexed,None>
- Parameters:
context
- Specifications.
-
loadMetaData
protected void loadMetaData(AbstractAsyncManagedObjectSource.MetaDataContext<Indexed,None> context) throws java.lang.Exception
Description copied from class:AbstractAsyncManagedObjectSource
Overridden to load meta-data.- Specified by:
loadMetaData
in 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:AbstractManagedObjectSource
Synchronously obtains theManagedObject
.- Specified by:
getManagedObject
in classAbstractManagedObjectSource<Indexed,None>
- Returns:
ManagedObject
.- Throws:
java.lang.Throwable
- If fails to obtain theManagedObject
.
-
-