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:
  Serializable, Model

    public class Model

extends Object
implements Serializable, Model

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.

Nested classes/interfaces inherited from interface play.db.Model
`Model.BinaryField, Model.Choices, Model.Factory, Model.Manager, Model.Property`

Field Summary
`static String` | `ALL`
`protected Map<String,Boolean>` | `blobFieldsTracker`

Constructor Summary
`Model()`

Method Summary
`static Long` | `_average(String field)`
`static Map<String,Long>` | `_cloud(String field)`
`void` | `_delete()`
`static Set<?>` | `_distinct(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
`Object` | `_key()`
`static Long` | `_max(String field)`
`static Long` | `_min(String field)`
`void` | `_save()`
`static Long` | `_sum(String field)`
`static
`<T extends Model> Model.MorphiaQuery`
` | `all()`
`protected boolean` | `blobChanged(String fieldName)`
`static DBCollection` | `col()` Return MongoDB DBCollection for this model
`static long` | `count()`
`static long` | `count(String keys, Object... params)`
`boolean` | `create()` store (ie insert) the entity.
`static
`<T extends Model> T`
` | `create(Class<?> type, String name, Map<String,String[]> params, Annotation[] annotations)`
`static Model` | `create(String name, Scope.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(Object o, String name, Map<String,String[]> params, Annotation[] annotations)`
`
`<T extends Model> T`
` | `edit(String name, Map<String,String[]> params)`
`boolean` | `equals(Object other)` For sub class with \@Embedded annotation specified, it's better to override this method
`static
`<T extends Model> Model.MorphiaQuery`
` | `filter(String property, Object value)` Morphia style filter method.
`static
`<T extends Model> Model.MorphiaQuery`
` | `find()` Shortcut to createQuery()
`static
`<T extends Model> Model.MorphiaQuery`
` | `find(String keys, Object... params)` JPA style find method
`static
`<T> List<T>`
` | `findAll()`
`static
`<T extends Model> T`
` | `findById(Object id)`
`static
`<T extends Model> T`
` | `get()` Return the first element in the data storage.
`String` | `getBlobFileName(String fieldName)`
`static String` | `getBlobFileName(String className, Object id, String fieldName)`
`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(Class<T> clazz)`
`static Model.Factory` | `getModelFactory()`
`static AggregationResult` | `groupAverage(String field, String... groupKeys)`
`static AggregationResult` | `groupCount(String field, String... groupKeys)`
`static AggregationResult` | `groupMax(String field, String... groupKeys)`
`static AggregationResult` | `groupMin(String field, String... groupKeys)`
`static AggregationResult` | `groupSum(String field, 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 Object` | `processId_(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(String keys, Object value)` Shortcut to find(String, Object...)
`
`<T extends Model> T`
` | `refresh()` Refresh the entity state.
`static void` | `removeGridFSFiles(Model.MorphiaQuery q, String... fieldNames)`
`static void` | `removeGridFSFiles(String className, Object id, String... fieldNames)`
`
`<T extends Model> T`
` | `save()` Save and return this entity
`Key<? extends Model>` | `save2()` Save and return Morphia Key
`protected void` | `saveBlobs()`
`protected void` | `setBlobChanged(String fieldName)`
`protected void` | `setId_(Object id)` MorphiaEnhancer will override this method for sub class without user annotated \@Id fields
`void` | `setId(Object id)`
`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 String ALL

See Also:
  Constant Field Values

### blobFieldsTracker

    protected final transient Map<String,Boolean> blobFieldsTracker

Constructor Detail

### Model

    public Model()

Method Detail

### _key

    public Object _key()

  Specified by:
    `_key` in interface `Model`

### _save

    public void _save()

  Specified by:
    `_save` in interface `Model`

### _delete

    public void _delete()

  Specified by:
    `_delete` in interface `Model`

### create

    public static <T extends Model> T create(Class<?> type,
                                             String name,
                                             Map<String,String[]> params,
                                             Annotation[] annotations)

### edit

    public static <T extends Model> T edit(Object o,
                                           String name,
                                           Map<String,String[]> params,
                                           Annotation[] annotations)

### edit

    public <T extends Model> T edit(String name,
                                    Map<String,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 Object processId_(Object id)

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

  Returns:

### getId

    public 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(Class<T> clazz)

### setId

    public final void setId(Object id)

### setId_

    protected void setId_(Object id)

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

### getModelFactory

    public static Model.Factory getModelFactory()

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### hashCode

    public int hashCode()

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

  Overrides:
    `hashCode` in class `Object`

### equals

    public boolean equals(Object other)

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

  Overrides:
    `equals` in class `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(String name,
                               Scope.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(String keys,
                             Object... params)

### _distinct

    public static Set<?> _distinct(String key)

  Return a Set of distinct values for the given key

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

### _max

    public static Long _max(String field)

### groupMax

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

### _min

    public static Long _min(String field)

### groupMin

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

### _average

    public static Long _average(String field)

### groupAverage

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

### _sum

    public static Long _sum(String field)

### groupSum

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

### groupCount

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

### _cloud

    public static Map<String,Long> _cloud(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(String keys,
                                                            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> List<T> findAll()

### findById

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

### q

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

  Shortcut to find(String, Object...)

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

### filter

    public static <T extends Model> Model.MorphiaQuery filter(String property,
                                                              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 Key<? extends Model> 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(String fieldName)

### setBlobChanged

    protected final void setBlobChanged(String fieldName)

### getBlobFileName

    public String getBlobFileName(String fieldName)

### getBlobFileName

    public static String getBlobFileName(String className,
                                         Object id,
                                         String fieldName)

### removeGridFSFiles

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

### removeGridFSFiles

    public static void removeGridFSFiles(Model.MorphiaQuery q,
                                         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

Copyright © 2012. All Rights Reserved.