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
`class` `JPAPlugin.TransactionalFilter`

### Nested classes/interfaces inherited from class play.PlayPlugin

`PlayPlugin.Filter<T>`

### Field Summary

Fields
`static boolean` `autoTxs`

### Fields inherited from class play.PlayPlugin

`index`

### Constructor Summary

Constructors
Constructor and Description
`JPAPlugin()`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
`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. see `JPA.rollbackTx(java.lang.String)` and `JPA.closeTx(java.lang.String)` method
`static javax.persistence.EntityManager` `createEntityManager()`
`javax.persistence.EntityManager` `em(java.lang.String key)`
`void` `enhance(ApplicationClasses.ApplicationClass applicationClass)` Enhance this class
`static java.lang.String` `getDefaultDialect(Configuration dbConfig, java.lang.String driver)`
`static java.lang.String` `getDefaultDialect(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`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### autoTxs

    public static boolean autoTxs

### Constructor Detail

#### JPAPlugin

    public JPAPlugin()

### 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 class `PlayPlugin`
Parameters:
  `rootParamNode` - parameters to bind
  `name` - the name of the object
  `clazz` - the class of the object to bind
  `type` - type
  `annotations` - 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 class `PlayPlugin`
Parameters:
  `rootParamNode` - parameters to bind
  `name` - the name of the object
  `bean` - 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 class `PlayPlugin`
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 class `PlayPlugin`

#### 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 class `PlayPlugin`

#### afterFixtureLoad

    public void afterFixtureLoad()

Overrides:
  `afterFixtureLoad` in class `PlayPlugin`

#### 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 class `PlayPlugin`

#### getFilter

    public PlayPlugin.Filter<java.lang.Object> getFilter()

Description copied from class: `PlayPlugin`
Return the filter implementation for this plugin.

Overrides:
  `getFilter` in class `PlayPlugin`
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() method
initialize the JPA context and starts a JPA transaction

Parameters:
  `readonly` - true for a readonly transaction

#### closeTx

    @Deprecated
    public static void closeTx(boolean rollback)

Deprecated. see `JPA.rollbackTx(java.lang.String)` and `JPA.closeTx(java.lang.String)` method
clear 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 class `PlayPlugin`
Parameters:
  `modelClass` - class of the model
Returns:
  the Model factory