using document oriënted database mongodb and the Object Document Mapper (ODM) morphia
Lets say we have 3 different classes; Object
, Category
and Action
.
These object are all stored in the collections; objects, categories and actions.
Category
and Action
are references of Object
@Entity("objects")
public class Object {
@Id
@Property("id")
private ObjectId id;
@Reference
private Category category;
private Action action;
...
}
@Entity("categories")
public class Category {
@Id
public String categoryTLA;
public String categoryName;
...
}
@Entity("actions")
public class Action implements BaseEntity {
@Id
public String action;
public int accesLevel;
...
}
The documents with the current implementation are stored like:
- Mongo (Server/location)
- store (database)
- objects (collection)
- object (document)
- object
- object
- categories
- categorie
- categorie
- categorie
- actions
- action
- action
- action
- objects (collection)
- store (database)
Is it possible to store 2 different Objects, in this case Category
and Action
, in one collection, like shown in the next example? Both with their own identification!
- Mongo
- store
- objects
- object
- object
- object
- settings
- categorie
- categorie
- categorie
- action
- action
- action
- objects
- store