java - Strategy for using Morphia to persist domain objects without adding unnecessary annotations to domain objects? -
Hypothetically, I can say that I have a domain object called person / P>
public class members {private last string first name; Private last string lastName; Private end string email; Private last string password; Public Member (String First Name, String Last Name, String Email, String Password) {this.firstName = firstName; This.lastName = lastName; This.email = email; This.password = password; } Public string getFirstName () {return firstName; } Public string getLastName () {lastName; } Public string getEmail () {return email; } Public string getPassword () {return password; }} I also have a member resume interface which defines the original CRUD and some other sweet methods.
Now we can say that I want to use this domain object as morphia in the Mongo DB example. I have created my Morphymbar Repository Implementation but I have uncertainty about the fact that the domain object is stored in as little as possible as possible.
Any morphia users will know that I will need to create an ID field, annotate it with type object id and with it the @ id . In addition, I will need to annotate the class with the @Entity ("member") . I do not necessarily want to disorganize my good domain object with morphia / Mongo DB specific annotation.
So ... fellow stacker, what should I do to keep this implementation as clean as possible?
Suppose that the emember is very the member's implementation email . GETTER MANAGEMENTS is defined in the IMAM.
Another class MorphiaMember tool IMember is annotated as required and the id field is (id is not always the Object ID). There is a factory method in each class
Public stable member (IMMB mi) {...} will be very specific workflow: < Pre> member repository repo = ... Member = Member (Repo.get (some_id)) ... Member M2 = ... repo.save (MorphiaMember.from (m))
Comments
Post a Comment