play.db.jpa

## Class GenericModel

- java.lang.Object
- - play.db.jpa.JPABase
  - - play.db.jpa.GenericModel

- All Implemented Interfaces:
    java.io.Serializable, Model
  Direct Known Subclasses:
    JPASupport, Model

      @MappedSuperclass
      public class GenericModel
      extends JPABase

  A super class for JPA entities
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `GenericModel.JPAQuery` A JPAQuery

    - ### Nested classes/interfaces inherited from class play.db.jpa.JPABase

      `JPABase.JPAQueryException`

    - ### Nested classes/interfaces inherited from interface play.db.Model

      `Model.BinaryField, Model.Choices, Model.Factory, Model.Manager, Model.Property`

  - ### Field Summary

    - ### Fields inherited from class play.db.jpa.JPABase

      `willBeSaved`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GenericModel()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `_saveAttachment()`
    `void` | `_setupAttachment()`
    `static GenericModel.JPAQuery` | `all()` Prepare a query to find *all* entities.
    `static long` | `count()` Count entities
    `static long` | `count(java.lang.String query, java.lang.Object... params)` Count entities with a special query.
    `boolean` | `create()` store (ie insert) the entity.
    `static <T extends JPABase> T` | `create(java.lang.Class<?> type, java.lang.String name, java.util.Map<java.lang.String,java.lang.String[]> params, java.lang.annotation.Annotation[] annotations)` Deprecated. use method {`create(ParamNode, String, Class, Annotation[])`}
    `static <T extends JPABase> T` | `create(ParamNode rootParamNode, java.lang.String name, java.lang.Class<?> type, java.lang.annotation.Annotation[] annotations)` Create a new model
    `static <T extends JPABase> T` | `create(java.lang.String name, Scope.Params params)` Create the new entity
    `<T extends JPABase> T` | `delete()` Delete the entity.
    `static int` | `delete(java.lang.String query, java.lang.Object... params)` Batch delete of entities
    `static int` | `deleteAll()` Delete all entities
    `static <T extends JPABase> T` | `edit(java.lang.Object o, java.lang.String name, java.util.Map<java.lang.String,java.lang.String[]> params, java.lang.annotation.Annotation[] annotations)` Deprecated. use method {`edit(ParamNode, String, Object, Annotation[])`}
    `<T extends GenericModel> T` | `edit(ParamNode rootParamNode, java.lang.String name)` Edit a model
    `static <T extends JPABase> T` | `edit(ParamNode rootParamNode, java.lang.String name, java.lang.Object o, java.lang.annotation.Annotation[] annotations)` Edit a model
    `<T extends GenericModel> T` | `edit(java.lang.String name, java.util.Map<java.lang.String,java.lang.String[]> params)` Deprecated. use method {`edit(ParamNode, String)`}
    `<T extends GenericModel> T` | `edit(java.lang.String dbName, ParamNode rootParamNode, java.lang.String name)` Edit a model
    `static <T extends JPABase> T` | `edit(java.lang.String dbName, ParamNode rootParamNode, java.lang.String name, java.lang.Object o, java.lang.annotation.Annotation[] annotations)` Edit a model
    `static GenericModel.JPAQuery` | `find(java.lang.String query, java.lang.Object... params)` Prepare a query to find entities.
    `static <T extends JPABase> java.util.List<T>` | `findAll()` Find all entities of this type
    `static <T extends JPABase> T` | `findById(java.lang.Object id)` Find the entity with the corresponding id.
    `<T extends JPABase> T` | `merge()` Merge this object to obtain a managed entity (useful when the object comes from the Cache).
    `<T extends JPABase> T` | `refresh()` Refresh the entity state.
    `<T extends JPABase> T` | `save()` store (ie insert) the entity.
    `boolean` | `validateAndCreate()` Validate and create the entity
    `boolean` | `validateAndSave()` Validate and store the entity

    - ### Methods inherited from class play.db.jpa.JPABase

      `_delete, _key, _save, em, em, equals, getEntityId, hashCode, isPersistent, isPersistent, toString`

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### GenericModel

          public GenericModel()

  - ### Method Detail

    - #### create

          @Deprecated
          public static <T extends JPABase> T create(java.lang.Class<?> type,
                                                                 java.lang.String name,
                                                                 java.util.Map<java.lang.String,java.lang.String[]> params,
                                                                 java.lang.annotation.Annotation[] annotations)

      Deprecated. use method {`create(ParamNode, String, Class, Annotation[])`}
      Create a new model
      Type Parameters:
        `T` - The entity class
      Parameters:
        `type` - the class of the object
        `name` - name of the object
        `params` - parameters used to create the new object
        `annotations` - annotations on the model
      Returns:
        The created entity

    - #### create

          public static <T extends JPABase> T create(ParamNode rootParamNode,
                                                     java.lang.String name,
                                                     java.lang.Class<?> type,
                                                     java.lang.annotation.Annotation[] annotations)

      Create a new model
      Type Parameters:
        `T` - The entity class
      Parameters:
        `rootParamNode` - parameters used to create the new object
        `name` - name of the object
        `type` - the class of the object
        `annotations` - annotations on the model
      Returns:
        The created entity

    - #### edit

          @Deprecated
          public static <T extends JPABase> T edit(java.lang.Object o,
                                                               java.lang.String name,
                                                               java.util.Map<java.lang.String,java.lang.String[]> params,
                                                               java.lang.annotation.Annotation[] annotations)

      Deprecated. use method {`edit(ParamNode, String, Object, Annotation[])`}
      Edit a model
      Type Parameters:
        `T` - class of the entity
      Parameters:
        `o` - Object to edit
        `name` - name of the object
        `params` - list of parameters
        `annotations` - annotations on the model
      Returns:
        the entity
      See Also:
        `edit(ParamNode, String, Object, Annotation[])`

    - #### edit

          public static <T extends JPABase> T edit(ParamNode rootParamNode,
                                                   java.lang.String name,
                                                   java.lang.Object o,
                                                   java.lang.annotation.Annotation[] annotations)

      Edit a model
      Type Parameters:
        `T` - class of the entity
      Parameters:
        `rootParamNode` - parameters used to create the new object
        `name` - name of the object
        `o` - the entity to update
        `annotations` - annotations on the model
      Returns:
        the entity

    - #### edit

          public static <T extends JPABase> T edit(java.lang.String dbName,
                                                   ParamNode rootParamNode,
                                                   java.lang.String name,
                                                   java.lang.Object o,
                                                   java.lang.annotation.Annotation[] annotations)

      Edit a model
      Type Parameters:
        `T` - class of the entity
      Parameters:
        `dbName` - the db name
        `rootParamNode` - parameters used to create the new object
        `name` - name of the object
        `o` - the entity to update
        `annotations` - annotations on the model
      Returns:
        the entity

    - #### edit

          @Deprecated
          public <T extends GenericModel> T edit(java.lang.String name,
                                                             java.util.Map<java.lang.String,java.lang.String[]> params)

      Deprecated. use method {`edit(ParamNode, String)`}
      Edit a model
      Type Parameters:
        `T` - class of the entity
      Parameters:
        `name` - name of the entity
        `params` - list of parameters
      Returns:
        the entity

    - #### edit

          public <T extends GenericModel> T edit(ParamNode rootParamNode,
                                                 java.lang.String name)

      Edit a model
      Type Parameters:
        `T` - class of the entity
      Parameters:
        `rootParamNode` - parameters used to create the new object
        `name` - name of the entity
      Returns:
        the entity

    - #### edit

          public <T extends GenericModel> T edit(java.lang.String dbName,
                                                 ParamNode rootParamNode,
                                                 java.lang.String name)

      Edit a model
      Type Parameters:
        `T` - class of the entity
      Parameters:
        `dbName` - the db name
        `rootParamNode` - parameters used to create the new object
        `name` - name of the entity
      Returns:
        the entity

    - #### validateAndSave

          public boolean validateAndSave()

      Validate and store the entity
      Returns:
        true if successful

    - #### validateAndCreate

          public boolean validateAndCreate()

      Validate and create the entity
      Returns:
        true if successful

    - #### save

          public <T extends JPABase> T save()

      store (ie insert) the entity.
      Type Parameters:
        `T` - class of the entity
      Returns:
        true if successful

    - #### create

          public boolean create()

      store (ie insert) the entity.
      Returns:
        true if successful

    - #### refresh

          public <T extends JPABase> T refresh()

      Refresh the entity state.
      Type Parameters:
        `T` - class of the entity
      Returns:
        The given entity

    - #### merge

          public <T extends JPABase> T merge()

      Merge this object to obtain a managed entity (useful when the object comes from the Cache).
      Type Parameters:
        `T` - class of the entity
      Returns:
        The given entity

    - #### delete

          public <T extends JPABase> T delete()

      Delete the entity.
      Type Parameters:
        `T` - class of the entity
      Returns:
        The deleted entity.

    - #### create

          public static <T extends JPABase> T create(java.lang.String name,
                                                     Scope.Params params)

      Create the new entity
      Type Parameters:
        `T` - class of the entity
      Parameters:
        `name` - name of the model
        `params` - list of parameters
      Returns:
        The created entity.

    - #### count

          public static long count()

      Count entities
      Returns:
        number of entities of this class

    - #### count

          public static long count(java.lang.String query,
                                   java.lang.Object... params)

      Count entities with a special query. Example : Long moderatedPosts = Post.count("moderated", true);
      Parameters:
        `query` - HQL query or shortcut
        `params` - Params to bind to the query
      Returns:
        A long

    - #### findAll

          public static <T extends JPABase> java.util.List<T> findAll()

      Find all entities of this type
      Type Parameters:
        `T` - the type of the entity
      Returns:
        All entities of this type

    - #### findById

          public static <T extends JPABase> T findById(java.lang.Object id)

      Find the entity with the corresponding id.
      Type Parameters:
        `T` - the type of the entity
      Parameters:
        `id` - The entity id
      Returns:
        The entity

    - #### find

          public static GenericModel.JPAQuery find(java.lang.String query,
                                                   java.lang.Object... params)

      Prepare a query to find entities.
      Parameters:
        `query` - HQL query or shortcut
        `params` - Params to bind to the query
      Returns:
        A JPAQuery

    - #### all

          public static GenericModel.JPAQuery all()

      Prepare a query to find *all* entities.
      Returns:
        A JPAQuery

    - #### delete

          public static int delete(java.lang.String query,
                                   java.lang.Object... params)

      Batch delete of entities
      Parameters:
        `query` - HQL query or shortcut
        `params` - Params to bind to the query
      Returns:
        Number of entities deleted

    - #### deleteAll

          public static int deleteAll()

      Delete all entities
      Returns:
        Number of entities deleted

    - #### _setupAttachment

          public void _setupAttachment()

    - #### _saveAttachment

          public void _saveAttachment()

Guillaume Bort & zenexity - Distributed under Apache 2 licence, without any warrantly