Package play.db.jpa
Class JPAPlugin
- java.lang.Object
-
- play.PlayPlugin
-
- play.db.jpa.JPAPlugin
-
- All Implemented Interfaces:
java.lang.Comparable<PlayPlugin>
public class JPAPlugin extends PlayPlugin
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
JPAPlugin.TransactionalFilter
-
Nested classes/interfaces inherited from class play.PlayPlugin
PlayPlugin.Filter<T>
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
autoTxs
-
Fields inherited from class play.PlayPlugin
index
-
-
Constructor Summary
Constructors Constructor Description JPAPlugin()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
afterFixtureLoad()
void
afterInvocation()
Called after an invocation.java.lang.Object
bind(RootParamNode rootParamNode, java.lang.String name, java.lang.Class clazz, java.lang.reflect.Type type, java.lang.annotation.Annotation[] annotations)
Called when play need to bind a Java object from HTTP params.java.lang.Object
bindBean(RootParamNode rootParamNode, java.lang.String name, java.lang.Object bean)
Called when play need to bind an existing Java object from HTTP params.static void
closeTx(boolean rollback)
Deprecated.seeJPA.rollbackTx(java.lang.String)
andJPA.closeTx(java.lang.String)
methodstatic javax.persistence.EntityManager
createEntityManager()
javax.persistence.EntityManager
em(java.lang.String key)
void
enhance(ApplicationClasses.ApplicationClass applicationClass)
Enhance this classstatic java.lang.String
getDefaultDialect(java.lang.String driver)
static java.lang.String
getDefaultDialect(Configuration dbConfig, java.lang.String driver)
PlayPlugin.Filter<java.lang.Object>
getFilter()
Return the filter implementation for this plugin.Model.Factory
modelFactory(java.lang.Class<? extends Model> modelClass)
protected javax.persistence.EntityManagerFactory
newEntityManagerFactory(java.lang.String dbName, Configuration dbConfig)
void
onApplicationStart()
Reads the configuration file and initialises required JPA EntityManagerFactories.void
onApplicationStop()
Called at application stop (and before each reloading) Time to shutdown stateful things.protected PersistenceUnitInfoImpl
persistenceUnitInfo(java.lang.String dbName, Configuration dbConfig)
protected java.util.Properties
properties(java.lang.String dbName, Configuration dbConfig)
static void
startTx(boolean readonly)
Deprecated.see JPA startTx() method-
Methods inherited from class play.PlayPlugin
addMimeTypes, addTemplateExtensions, afterActionInvocation, afterApplicationStart, beforeActionInvocation, beforeDetectingChanges, beforeInvocation, bind, bind, compareTo, compileAll, compileSources, detectChange, detectClassesChange, getFunctionalTests, getJsonStatus, getMessage, getStatus, getUnitTests, hasFilter, invocationFinally, loadTemplate, onActionInvocationFinally, onActionInvocationResult, onApplicationReady, onClassesChange, onConfigurationRead, onEvent, onInvocationException, onInvocationSuccess, onLoad, onRequestRouting, onRoutesLoaded, onTemplateCompilation, overrideTemplateSource, postEvent, rawInvocation, routeRequest, runTest, serveStatic, unBind, willBeValidated
-
-
-
-
Method Detail
-
bind
public java.lang.Object bind(RootParamNode rootParamNode, java.lang.String name, java.lang.Class clazz, java.lang.reflect.Type type, java.lang.annotation.Annotation[] annotations)
Description copied from class:PlayPlugin
Called when play need to bind a Java object from HTTP params. When overriding this method, do not call super impl.. super impl is calling old bind method to be backward compatible.- Overrides:
bind
in classPlayPlugin
- Parameters:
rootParamNode
- parameters to bindname
- the name of the objectclazz
- the class of the object to bindtype
- typeannotations
- annotation on the object- Returns:
- binding object
-
bindBean
public java.lang.Object bindBean(RootParamNode rootParamNode, java.lang.String name, java.lang.Object bean)
Description copied from class:PlayPlugin
Called when play need to bind an existing Java object from HTTP params. When overriding this method, DO NOT call the super method, since its default impl is to call the old bind method to be backward compatible.- Overrides:
bindBean
in classPlayPlugin
- Parameters:
rootParamNode
- parameters to bindname
- the name of the objectbean
- object to bind- Returns:
- binding object
-
enhance
public void enhance(ApplicationClasses.ApplicationClass applicationClass) throws java.lang.Exception
Description copied from class:PlayPlugin
Enhance this class- Overrides:
enhance
in classPlayPlugin
- Parameters:
applicationClass
- the class to enhance- Throws:
java.lang.Exception
- if cannot enhance the class
-
em
public javax.persistence.EntityManager em(java.lang.String key)
-
onApplicationStart
public void onApplicationStart()
Reads the configuration file and initialises required JPA EntityManagerFactories.- Overrides:
onApplicationStart
in classPlayPlugin
-
newEntityManagerFactory
protected javax.persistence.EntityManagerFactory newEntityManagerFactory(java.lang.String dbName, Configuration dbConfig)
-
persistenceUnitInfo
protected PersistenceUnitInfoImpl persistenceUnitInfo(java.lang.String dbName, Configuration dbConfig)
-
properties
protected java.util.Properties properties(java.lang.String dbName, Configuration dbConfig)
-
getDefaultDialect
public static java.lang.String getDefaultDialect(java.lang.String driver)
-
getDefaultDialect
public static java.lang.String getDefaultDialect(Configuration dbConfig, java.lang.String driver)
-
onApplicationStop
public void onApplicationStop()
Description copied from class:PlayPlugin
Called at application stop (and before each reloading) Time to shutdown stateful things.- Overrides:
onApplicationStop
in classPlayPlugin
-
afterFixtureLoad
public void afterFixtureLoad()
- Overrides:
afterFixtureLoad
in classPlayPlugin
-
afterInvocation
public void afterInvocation()
Description copied from class:PlayPlugin
Called after an invocation. (unless an exception has been thrown). Time to close request specific things.- Overrides:
afterInvocation
in classPlayPlugin
-
getFilter
public PlayPlugin.Filter<java.lang.Object> getFilter()
Description copied from class:PlayPlugin
Return the filter implementation for this plugin.- Overrides:
getFilter
in classPlayPlugin
- Returns:
- filter object of this plugin
-
createEntityManager
public static javax.persistence.EntityManager createEntityManager()
-
startTx
@Deprecated public static void startTx(boolean readonly)
Deprecated.see JPA startTx() methodinitialize the JPA context and starts a JPA transaction- Parameters:
readonly
- true for a readonly transaction
-
closeTx
@Deprecated public static void closeTx(boolean rollback)
Deprecated.seeJPA.rollbackTx(java.lang.String)
andJPA.closeTx(java.lang.String)
methodclear current JPA context and transaction- Parameters:
rollback
- shall current transaction be committed (false) or cancelled (true)
-
modelFactory
public Model.Factory modelFactory(java.lang.Class<? extends Model> modelClass)
- Overrides:
modelFactory
in classPlayPlugin
- Parameters:
modelClass
- class of the model- Returns:
- the Model factory
-
-