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 classJPAPlugin.TransactionalFilter-
Nested classes/interfaces inherited from class play.PlayPlugin
PlayPlugin.Filter<T>
-
-
Field Summary
Fields Modifier and Type Field Description static booleanautoTxs-
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 voidafterFixtureLoad()voidafterInvocation()Called after an invocation.java.lang.Objectbind(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.ObjectbindBean(RootParamNode rootParamNode, java.lang.String name, java.lang.Object bean)Called when play need to bind an existing Java object from HTTP params.static voidcloseTx(boolean rollback)Deprecated.seeJPA.rollbackTx(java.lang.String)andJPA.closeTx(java.lang.String)methodstatic javax.persistence.EntityManagercreateEntityManager()javax.persistence.EntityManagerem(java.lang.String key)voidenhance(ApplicationClasses.ApplicationClass applicationClass)Enhance this classstatic java.lang.StringgetDefaultDialect(java.lang.String driver)static java.lang.StringgetDefaultDialect(Configuration dbConfig, java.lang.String driver)PlayPlugin.Filter<java.lang.Object>getFilter()Return the filter implementation for this plugin.Model.FactorymodelFactory(java.lang.Class<? extends Model> modelClass)protected javax.persistence.EntityManagerFactorynewEntityManagerFactory(java.lang.String dbName, Configuration dbConfig)voidonApplicationStart()Reads the configuration file and initialises required JPA EntityManagerFactories.voidonApplicationStop()Called at application stop (and before each reloading) Time to shutdown stateful things.protected PersistenceUnitInfoImplpersistenceUnitInfo(java.lang.String dbName, Configuration dbConfig)protected java.util.Propertiesproperties(java.lang.String dbName, Configuration dbConfig)static voidstartTx(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:PlayPluginCalled 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:
bindin 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:PlayPluginCalled 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:
bindBeanin 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:PlayPluginEnhance this class- Overrides:
enhancein 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:
onApplicationStartin 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:PlayPluginCalled at application stop (and before each reloading) Time to shutdown stateful things.- Overrides:
onApplicationStopin classPlayPlugin
-
afterFixtureLoad
public void afterFixtureLoad()
- Overrides:
afterFixtureLoadin classPlayPlugin
-
afterInvocation
public void afterInvocation()
Description copied from class:PlayPluginCalled after an invocation. (unless an exception has been thrown). Time to close request specific things.- Overrides:
afterInvocationin classPlayPlugin
-
getFilter
public PlayPlugin.Filter<java.lang.Object> getFilter()
Description copied from class:PlayPluginReturn the filter implementation for this plugin.- Overrides:
getFilterin 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:
modelFactoryin classPlayPlugin- Parameters:
modelClass- class of the model- Returns:
- the Model factory
-
-