Re: [morphia] Morphia - java ODM - Dynamic schema?

25 views
Skip to first unread message
Message has been deleted

green

unread,
Feb 21, 2018, 4:10:07 PM2/21/18
to mor...@googlegroups.com
Hi Ramesh,

What's the exception? MongoDB is a document database there shouldn't have any schema in your collection.


On Thu, Feb 22, 2018 at 8:07 AM Ramesh Sibi <sibi...@gmail.com> wrote:
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?

--
You received this message because you are subscribed to the Google Groups "Morphia" group.
To unsubscribe from this group and stop receiving emails from it, send an email to morphia+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages