Package play.db.jpa

Class JPAPlugin

  • All Implemented Interfaces:
    java.lang.Comparable<PlayPlugin>

    public class JPAPlugin
    extends PlayPlugin
    • 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)
      • 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
      • 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
      • 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