Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## play.modules.morphia
Class Model

    java.lang.Object
      play.modules.morphia.Model

All Implemented Interfaces:
  java.io.Serializable

    public class Model

extends java.lang.Object
implements java.io.Serializable

This class provides the abstract declarations for all Models. Implementations of these declarations are provided by the MorphiaEnhancer.

Author:
  greenlaw110@gmail.com
See Also:
  Serialized Form

Nested Class Summary
`static interface` | `Model.Added` Added mark a method be called after an new entity is saved.
`static interface` | `Model.AutoTimestamp`
`static interface` | `Model.BatchDeleted` Deleted mark a method be called after an a query deletion executed
`static interface` | `Model.ByPass`
`static interface` | `Model.Column`
`static interface` | `Model.Deleted` Deleted mark a method be called after an entity is deleted
`static interface` | `Model.Loaded` OnLoad mark a method be called immediately after an entity loaded from mongodb
`static class` | `Model.MorphiaQuery`
`static interface` | `Model.NoId` NoID is used to annotate on sub types which is sure to get ID field from parent type
`static interface` | `Model.OnAdd` OnAdd mark a method be called before an new entity is saved.
`static interface` | `Model.OnBatchDelete` OnBatchDelete mark a method be called before a query's delete method get called.
`static interface` | `Model.OnDelete` OnDelete mark a method be called before an entity is deleted.
`static interface` | `Model.OnLoad` OnLoad mark a method be called after an new instance of an entity is initialized and before the properties are filled with mongo db columns
`static interface` | `Model.OnUpdate` OnUpdate mark a method be called before an existing entity is saved.
`static interface` | `Model.Updated` Updated mark a method be called after an existing entity is saved.

Field Summary
`static java.lang.String` | `ALL`
`protected java.util.Map<java.lang.String,java.lang.Boolean>` | `blobFieldsTracker`

Constructor Summary
`Model()`

Method Summary
`static java.lang.Long` | `_average(java.lang.String field)`
`static java.util.Map<java.lang.String,java.lang.Long>` | `_cloud(java.lang.String field)`
`void` | `_delete()`
`static java.util.Set<?>` | `_distinct(java.lang.String key)` Return a Set of distinct values for the given key
`long` | `_getCreated()`
`long` | `_getModified()`
`void` | `_h_Loaded()` for PlayMorphia internal usage only
`void` | `_h_OnLoad()` for PlayMorphia internal usage only
`java.lang.Object` | `_key()`
`static java.lang.Long` | `_max(java.lang.String field)`
`static java.lang.Long` | `_min(java.lang.String field)`
`void` | `_save()`
`static java.lang.Long` | `_sum(java.lang.String field)`
`static
`<T extends Model> Model.MorphiaQuery`
` | `all()`
`protected boolean` | `blobChanged(java.lang.String fieldName)`
`static DBCollection` | `col()` Return MongoDB DBCollection for this model
`static long` | `count()`
`static long` | `count(java.lang.String keys, java.lang.Object... params)`
`boolean` | `create()` store (ie insert) the entity.
`static
`<T extends Model> 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 Model` | `create(java.lang.String name, Params params)`
`static
`<T extends Model> Model.MorphiaQuery`
` | `createQuery()`
`static DB` | `db()` Return MongoDB DB instance
`
`<T extends Model> T`
` | `delete()`
`static long` | `delete(Model.MorphiaQuery query)`
`static long` | `deleteAll()` Shortcut to Model.delete(find())
`protected void` | `deleteBlobs()`
`protected void` | `deleteBlobsInBatch(Model.MorphiaQuery q)`
`static
`<T extends Model> Model.MorphiaQuery`
` | `disableValidation()`
`static Datastore` | `ds()` Return Morphia Datastore instance
`static
`<T extends Model> 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 Model> T`
` | `edit(java.lang.String name, java.util.Map<java.lang.String,java.lang.String[]> params)`
`boolean` | `equals(java.lang.Object other)` For sub class with \@Embedded annotation specified, it's better to override this method
`static
`<T extends Model> Model.MorphiaQuery`
` | `filter(java.lang.String property, java.lang.Object value)` Morphia style filter method.
`static
`<T extends Model> Model.MorphiaQuery`
` | `find()` Shortcut to createQuery()
`static
`<T extends Model> Model.MorphiaQuery`
` | `find(java.lang.String keys, java.lang.Object... params)` JPA style find method
`static
`<T> java.util.List<T>`
` | `findAll()`
`static
`<T extends Model> T`
` | `findById(java.lang.Object id)`
`static
`<T extends Model> T`
` | `get()` Return the first element in the data storage.
`java.lang.String` | `getBlobFileName(java.lang.String fieldName)`
`static java.lang.String` | `getBlobFileName(java.lang.String className, java.lang.Object id, java.lang.String fieldName)`
`java.lang.Object` | `getId()` MorphiaEnhancer will override this method for sub class without \@Embedded annotation specified If user defined customized \@Id field, it's better to override this method for the sake of performance.
`
`<T> T`
` | `getId(java.lang.Class<T> clazz)`
`static play.db.Model.Factory` | `getModelFactory()`
`static AggregationResult` | `groupAverage(java.lang.String field, java.lang.String... groupKeys)`
`static AggregationResult` | `groupCount(java.lang.String field, java.lang.String... groupKeys)`
`static AggregationResult` | `groupMax(java.lang.String field, java.lang.String... groupKeys)`
`static AggregationResult` | `groupMin(java.lang.String field, java.lang.String... groupKeys)`
`static AggregationResult` | `groupSum(java.lang.String field, java.lang.String... groupKeys)`
`protected void` | `h_Added()` for PlayMorphia internal usage only
`protected void` | `h_BatchDeleted(Model.MorphiaQuery q)`
`protected void` | `h_Deleted()`
`protected void` | `h_Loaded()` for PlayMorphia internal usage only
`protected void` | `h_OnAdd()` for PlayMorphia internal usage only
`protected void` | `h_OnBatchDelete(Model.MorphiaQuery q)`
`protected void` | `h_OnDelete()`
`protected void` | `h_OnLoad()` for PlayMorphia internal usage only
`protected void` | `h_OnUpdate()` for PlayMorphia internal usage only
`protected void` | `h_Updated()` for PlayMorphia internal usage only
`int` | `hashCode()` For sub class with \@Embedded annotation specified, it's better to override this method
`protected boolean` | `isEmbedded_()` Deprecated.
`boolean` | `isNew()` A utility method determine whether this entity is a newly constructed object in memory or represents a data from mongodb
`protected boolean` | `isUserDefinedId_()` MorphiaEnhancer will override this method for sub class with \@Id annotation specified
`protected void` | `loadBlobs()`
`
`<T extends Model> T`
` | `merge()` This method has no effect at all
`protected static java.lang.Object` | `processId_(java.lang.Object id)` Any sub class with \@Id annotation specified need to rewrite this method
`static
`<T extends Model> Model.MorphiaQuery`
` | `q()` Shortcut to createQuery
`static
`<T extends Model> Model.MorphiaQuery`
` | `q(java.lang.String keys, java.lang.Object value)` Shortcut to find(String, Object...)
`
`<T extends Model> T`
` | `refresh()` Refresh the entity state.
`static void` | `removeGridFSFiles(Model.MorphiaQuery q, java.lang.String... fieldNames)`
`static void` | `removeGridFSFiles(java.lang.String className, java.lang.Object id, java.lang.String... fieldNames)`
`
`<T extends Model> T`
` | `save()` Save and return this entity
`` | `save2()` Save and return Morphia Key
`protected void` | `saveBlobs()`
`protected void` | `setBlobChanged(java.lang.String fieldName)`
`protected void` | `setId_(java.lang.Object id)` MorphiaEnhancer will override this method for sub class without user annotated \@Id fields
`void` | `setId(java.lang.Object id)`
`java.lang.String` | `toString()`
`boolean` | `validateAndCreate()`
`boolean` | `validateAndSave()`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### ALL

    public static final java.lang.String ALL

See Also:
  Constant Field Values

### blobFieldsTracker

    protected final java.util.Map<java.lang.String,java.lang.Boolean> blobFieldsTracker

Constructor Detail

### Model

    public Model()

Method Detail

### _key

    public java.lang.Object _key()

### _save

    public void _save()

### _delete

    public void _delete()

### create

    public static <T extends Model> 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 Model> 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 Model> T edit(java.lang.String name,
                                    java.util.Map<java.lang.String,java.lang.String[]> params)

### validateAndSave

    public boolean validateAndSave()

### validateAndCreate

    public boolean validateAndCreate()

### isEmbedded_

    protected boolean isEmbedded_()

  Deprecated.

  This method is deprecated as Embedded object shall not extends Model class and shall not be enhanced

  Returns:

### isUserDefinedId_

    protected boolean isUserDefinedId_()

  MorphiaEnhancer will override this method for sub class with \@Id annotation specified

  Returns:

### processId_

    protected static java.lang.Object processId_(java.lang.Object id)

  Any sub class with \@Id annotation specified need to rewrite this method

  Returns:

### getId

    public java.lang.Object getId()

  MorphiaEnhancer will override this method for sub class without \@Embedded annotation specified If user defined customized \@Id field, it's better to override this method for the sake of performance. Otherwise framework will use reflection to get the value

  Returns:

### getId

    public <T> T getId(java.lang.Class<T> clazz)

### setId

    public final void setId(java.lang.Object id)

### setId_

    protected void setId_(java.lang.Object id)

  MorphiaEnhancer will override this method for sub class without user annotated \@Id fields

### getModelFactory

    public static play.db.Model.Factory getModelFactory()

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### hashCode

    public int hashCode()

  For sub class with \@Embedded annotation specified, it's better to override this method

  Overrides:
    `hashCode` in class `java.lang.Object`

### equals

    public boolean equals(java.lang.Object other)

  For sub class with \@Embedded annotation specified, it's better to override this method

  Overrides:
    `equals` in class `java.lang.Object`

### isNew

    public final boolean isNew()

  A utility method determine whether this entity is a newly constructed object in memory or represents a data from mongodb

  Returns:
    true if this is a memory object which has not been saved to db yet, false otherwise

### merge

    public <T extends Model> T merge()

  This method has no effect at all

### refresh

    public <T extends Model> T refresh()

  Refresh the entity state.

### all

    public static <T extends Model> Model.MorphiaQuery all()

### create

    public static Model create(java.lang.String name,
                               Params params)

### q

    public static <T extends Model> Model.MorphiaQuery q()

  Shortcut to createQuery

  Returns:

### createQuery

    public static <T extends Model> Model.MorphiaQuery createQuery()

### disableValidation

    public static <T extends Model> Model.MorphiaQuery disableValidation()

### count

    public static long count()

### count

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

### _distinct

    public static java.util.Set<?> _distinct(java.lang.String key)

  Return a Set of distinct values for the given key

  Parameters:
    `key` -
  Returns:
    a distinct set of key values

### _max

    public static java.lang.Long _max(java.lang.String field)

### groupMax

    public static AggregationResult groupMax(java.lang.String field,
                                             java.lang.String... groupKeys)

### _min

    public static java.lang.Long _min(java.lang.String field)

### groupMin

    public static AggregationResult groupMin(java.lang.String field,
                                             java.lang.String... groupKeys)

### _average

    public static java.lang.Long _average(java.lang.String field)

### groupAverage

    public static AggregationResult groupAverage(java.lang.String field,
                                                 java.lang.String... groupKeys)

### _sum

    public static java.lang.Long _sum(java.lang.String field)

### groupSum

    public static AggregationResult groupSum(java.lang.String field,
                                             java.lang.String... groupKeys)

### groupCount

    public static AggregationResult groupCount(java.lang.String field,
                                               java.lang.String... groupKeys)

### _cloud

    public static java.util.Map<java.lang.String,java.lang.Long> _cloud(java.lang.String field)

### delete

    public <T extends Model> T delete()

### h_OnDelete

    protected void h_OnDelete()

### h_Deleted

    protected void h_Deleted()

### h_OnBatchDelete

    protected void h_OnBatchDelete(Model.MorphiaQuery q)

### h_BatchDeleted

    protected void h_BatchDeleted(Model.MorphiaQuery q)

### deleteBlobs

    protected void deleteBlobs()

### deleteBlobsInBatch

    protected void deleteBlobsInBatch(Model.MorphiaQuery q)

### create

    public boolean create()

  store (ie insert) the entity.

### delete

    public static long delete(Model.MorphiaQuery query)

### deleteAll

    public static long deleteAll()

  Shortcut to Model.delete(find())

  Returns:

### find

    public static <T extends Model> Model.MorphiaQuery find()

  Shortcut to createQuery()

  Returns:

### find

    public static <T extends Model> Model.MorphiaQuery find(java.lang.String keys,
                                                            java.lang.Object... params)

  JPA style find method

  Parameters:
    `keys` - could be either "byKey1[AndKey2[AndKey3...]]" or "Key1[AndKey2[AndKey3...]]" or "key1 key2..."
    `params` - number should either be one or the same number of keys
  Returns:

### findAll

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

### findById

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

### q

    public static <T extends Model> Model.MorphiaQuery q(java.lang.String keys,
                                                         java.lang.Object value)

  Shortcut to find(String, Object...)

  Parameters:
    `keys` -
    `objects` -
  Returns:

### filter

    public static <T extends Model> Model.MorphiaQuery filter(java.lang.String property,
                                                              java.lang.Object value)

  Morphia style filter method.

  if you have MyModel.find("byNameAndAge", "John", 20), you can also use MyModel.filter("name", "John").filter("age", 20) for the same query

  Parameters:
    `property` - should be the filter name
    `value` - the filter value
  Returns:

### get

    public static <T extends Model> T get()

  Return the first element in the data storage. Return null if there is no record found

### ds

    public static Datastore ds()

  Return Morphia Datastore instance

  Returns:

### col

    public static DBCollection col()

  Return MongoDB DBCollection for this model

### db

    public static DB db()

  Return MongoDB DB instance

  Returns:

### save

    public <T extends Model> T save()

  Save and return this entity

  Type Parameters:
    `T` -
  Returns:

### save2

    public  save2()

  Save and return Morphia Key

  Returns:

### _h_OnLoad

    public final void _h_OnLoad()

  for PlayMorphia internal usage only

### h_OnLoad

    protected void h_OnLoad()

  for PlayMorphia internal usage only

### _h_Loaded

    public final void _h_Loaded()

  for PlayMorphia internal usage only

### h_Loaded

    protected void h_Loaded()

  for PlayMorphia internal usage only

### h_Added

    protected void h_Added()

  for PlayMorphia internal usage only

### h_Updated

    protected void h_Updated()

  for PlayMorphia internal usage only

### h_OnAdd

    protected void h_OnAdd()

  for PlayMorphia internal usage only

### h_OnUpdate

    protected void h_OnUpdate()

  for PlayMorphia internal usage only

### saveBlobs

    protected void saveBlobs()

### loadBlobs

    protected void loadBlobs()

### blobChanged

    protected final boolean blobChanged(java.lang.String fieldName)

### setBlobChanged

    protected final void setBlobChanged(java.lang.String fieldName)

### getBlobFileName

    public java.lang.String getBlobFileName(java.lang.String fieldName)

### getBlobFileName

    public static java.lang.String getBlobFileName(java.lang.String className,
                                                   java.lang.Object id,
                                                   java.lang.String fieldName)

### removeGridFSFiles

    public static void removeGridFSFiles(java.lang.String className,
                                         java.lang.Object id,
                                         java.lang.String... fieldNames)

### removeGridFSFiles

    public static void removeGridFSFiles(Model.MorphiaQuery q,
                                         java.lang.String... fieldNames)

### _getCreated

    public long _getCreated()

### _getModified

    public long _getModified()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD