Hi ,
I am using Morphia 1.3.1 for mapping mongo DB documents to java objects (ODM).
I would like to achieve dynamic schema changes capability to the application being developed.
For example:
let's say , i have below document structure in a collection(Person).
{
firstName: xxxx,
lastName: xxxx
}
we are mapping this in java using Morphia like below.
@Entity("Person")
class Person {
private String firstName;
private String lastName;
//getters and setters for above fields.......
}
if we are to add a new field in the class which could be available only in some documents in the collection(Person).
say...(highlighted field)
@Entity("Person")
class Person {
private String firstName;
private String lastName;
private String middleName;
//getters and setters for above fields.......
}
In this case, morphia throws exception. So Morphia seems to make the schema rigid.
Could you please let me know, if there is a workaround to keep the schema dynamic for a given collection while using Morphia as the ODM?