play.db.jpa
Class GenericModel

java.lang.Object
  extended by play.db.jpa.JPABase
      extended by 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
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
GenericModel()
           
 
Method Summary
 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.
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)
           
static
<T extends JPABase>
T
create(java.lang.String name, Scope.Params params)
           
<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)
           
<T extends GenericModel>
T
edit(java.lang.String name, java.util.Map<java.lang.String,java.lang.String[]> params)
           
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 (usefull 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 validateAndSave()
           
 
Methods inherited from class play.db.jpa.JPABase
_delete, _key, _save, em, equals, getEntityId, hashCode, 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

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)

edit

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)

edit

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

validateAndSave

public boolean validateAndSave()

save

public <T extends JPABase> T save()
store (ie insert) the entity.


refresh

public <T extends JPABase> T refresh()
Refresh the entity state.


merge

public <T extends JPABase> T merge()
Merge this object to obtain a managed entity (usefull when the object comes from the Cache).


delete

public <T extends JPABase> T delete()
Delete the entity.

Returns:
The deleted entity.

create

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

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


findById

public static <T extends JPABase> T findById(java.lang.Object id)
Find the entity with the corresponding id.

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