Package play.db.jpa

Class GenericModel

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

    @MappedSuperclass
    public class GenericModel
    extends JPABase
    A super class for JPA entities
    See Also:
    Serialized Form
    • Constructor Detail

      • GenericModel

        public GenericModel()
    • Method Detail

      • create

        @Nonnull
        public static <T extends JPABase> T create​(Http.Request request,
                                                   Scope.Session session,
                                                   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

        @Nonnull
        public static <T extends JPABase> T edit​(Http.Request request,
                                                 Scope.Session session,
                                                 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

        @Nonnull
        public <T extends GenericModel> T edit​(Http.Request request,
                                               Scope.Session session,
                                               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
      • save

        @Nonnull
        public <T extends JPABase> T save()
      • merge

        @Nonnull
        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

        @Nonnull
        public <T extends JPABase> T delete()
        Delete the entity.
        Type Parameters:
        T - class of the entity
        Returns:
        The deleted entity.