|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectplay.modules.morphia.Model
public class Model
This class provides the abstract declarations for all Models. Implementations of these declarations are provided by the MorphiaEnhancer.
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 class |
Model.MorphiaUpdateOperations
|
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
|
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
|
create(Class<?> type,
String name,
Map<String,String[]> params,
Annotation[] annotations)
|
|
static Model |
create(String name,
Scope.Params params)
|
|
static
|
createQuery()
|
|
static
|
createUpdateOperations()
|
|
static DB |
db()
Return MongoDB DB instance |
|
|
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
|
disableValidation()
|
|
static Datastore |
ds()
Return Morphia Datastore instance |
|
static
|
edit(Object o,
String name,
Map<String,String[]> params,
Annotation[] annotations)
|
|
|
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
|
filter(String property,
Object value)
Morphia style filter method. |
|
static
|
find()
Shortcut to createQuery() |
|
static
|
find(String keys,
Object... params)
JPA style find method |
|
static
|
findAll()
|
|
static
|
findById(Object id)
|
|
static
|
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. |
|
|
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()
|
|
|
merge()
This method has no effect at all |
|
static
|
o()
Alias of #updateOperations() |
|
protected static Object |
processId_(Object id)
Any sub class with \@Id annotation specified need to rewrite this method |
|
static
|
q()
Shortcut to createQuery |
|
static
|
q(String keys,
Object value)
Shortcut to find(String, Object...) |
|
|
refresh()
Refresh the entity state. |
|
static void |
removeGridFSFiles(Model.MorphiaQuery q,
String... fieldNames)
|
|
static void |
removeGridFSFiles(String className,
Object id,
String... fieldNames)
|
|
|
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 |
---|
public static final String ALL
protected final transient Map<String,Boolean> blobFieldsTracker
Constructor Detail |
---|
public Model()
Method Detail |
---|
public Object _key()
_key
in interface Model
public void _save()
_save
in interface Model
public void _delete()
_delete
in interface Model
public static <T extends Model> T create(Class<?> type, String name, Map<String,String[]> params, Annotation[] annotations)
public static <T extends Model> T edit(Object o, String name, Map<String,String[]> params, Annotation[] annotations)
public <T extends Model> T edit(String name, Map<String,String[]> params)
public boolean validateAndSave()
public boolean validateAndCreate()
protected boolean isEmbedded_()
protected boolean isUserDefinedId_()
protected static Object processId_(Object id)
public Object getId()
public <T> T getId(Class<T> clazz)
public final void setId(Object id)
protected void setId_(Object id)
public static Model.Factory getModelFactory()
public String toString()
toString
in class Object
public int hashCode()
hashCode
in class Object
public boolean equals(Object other)
equals
in class Object
public final boolean isNew()
public <T extends Model> T merge()
public <T extends Model> T refresh()
public static <T extends Model> Model.MorphiaQuery all()
public static Model create(String name, Scope.Params params)
public static <T extends Model> Model.MorphiaQuery q()
public static <T extends Model> Model.MorphiaQuery createQuery()
public static <T extends Model> Model.MorphiaQuery disableValidation()
public static long count()
public static long count(String keys, Object... params)
public static Set<?> _distinct(String key)
key
-
public static Long _max(String field)
public static AggregationResult groupMax(String field, String... groupKeys)
public static Long _min(String field)
public static AggregationResult groupMin(String field, String... groupKeys)
public static Long _average(String field)
public static AggregationResult groupAverage(String field, String... groupKeys)
public static Long _sum(String field)
public static AggregationResult groupSum(String field, String... groupKeys)
public static AggregationResult groupCount(String field, String... groupKeys)
public static Map<String,Long> _cloud(String field)
public <T extends Model> T delete()
protected void h_OnDelete()
protected void h_Deleted()
protected void h_OnBatchDelete(Model.MorphiaQuery q)
protected void h_BatchDeleted(Model.MorphiaQuery q)
protected void deleteBlobs()
protected void deleteBlobsInBatch(Model.MorphiaQuery q)
public boolean create()
public static long delete(Model.MorphiaQuery query)
public static long deleteAll()
public static <T extends Model> Model.MorphiaQuery find()
public static <T extends Model> Model.MorphiaQuery find(String keys, Object... params)
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
public static <T> List<T> findAll()
public static <T extends Model> T findById(Object id)
public static <T extends Model> Model.MorphiaQuery q(String keys, Object value)
keys
- keys
-
public static <T extends Model> Model.MorphiaQuery filter(String property, Object value)
if you have MyModel.find("byNameAndAge", "John", 20), you can also use MyModel.filter("name", "John").filter("age", 20) for the same query
property
- should be the filter namevalue
- the filter value
public static <T extends Model> Model.MorphiaUpdateOperations createUpdateOperations()
public static <T extends Model> Model.MorphiaUpdateOperations o()
T
-
public static <T extends Model> T get()
public static Datastore ds()
public static DBCollection col()
public static DB db()
public <T extends Model> T save()
T
-
public Key<? extends Model> save2()
public final void _h_OnLoad()
protected void h_OnLoad()
public final void _h_Loaded()
protected void h_Loaded()
protected void h_Added()
protected void h_Updated()
protected void h_OnAdd()
protected void h_OnUpdate()
protected void saveBlobs()
protected void loadBlobs()
protected final boolean blobChanged(String fieldName)
protected final void setBlobChanged(String fieldName)
public String getBlobFileName(String fieldName)
public static String getBlobFileName(String className, Object id, String fieldName)
public static void removeGridFSFiles(String className, Object id, String... fieldNames)
public static void removeGridFSFiles(Model.MorphiaQuery q, String... fieldNames)
public long _getCreated()
public long _getModified()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |