-
Notifications
You must be signed in to change notification settings - Fork 455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support full constructors #581
Comments
Can you give an example of what you mean? |
It was inspired partly from the DDD book (Eric Evans) and partly from If you get rid of no-arg constructors and provide a single constructor that I noticed the other day Spring Data will use a constructor that accepts So: public class Person { private final Date dob; public Person(Date dob, String firstName, String lastName) { public Date getDateOfBirth() { public String getFirstName() { public String getLastName() { // Other methods for business use. } On 27 February 2014 11:45, Justin Lee notifications@github.com wrote:
|
Well, the constructor part I got. You'd just lost me with the factory part. There was a similar request/conversation about @constructor arguments elsewhere, too. This is probably a good idea. Provides a bit of flexibility for users. The mapping code is likely to change along with the 3.x java driver integration so I'd like to defer this until that picture becomes clearer. Morphia's perfectly happy without getters/setters for the record, though, so this feature is probably less pressing than many think. But I know a many devs hate adding no-arg constructors simply for the sake of persistence/serialization frameworks so this should probably happen either way. |
Where the wiki has an entity being described, I think you have a comment Agree about deferring, just want it as a desirable on the radar. On 27 February 2014 12:48, Justin Lee notifications@github.com wrote:
|
Good point. i'll tweak that wiki entry. On Thu, Feb 27, 2014 at 7:50 AM, James Green notifications@github.comwrote:
|
Morphia can’t deal with immutable entities. There is an issue for this: MorphiaOrg/morphia#581
It would be nice to see support for constructors that accepted each field as an argument.
This will let clients construct immutable entities without having to wire in custom object factories.
The text was updated successfully, but these errors were encountered: