Skip to content
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

A few comments on your readme #3

Open
odrotbohm opened this issue Dec 4, 2021 · 0 comments
Open

A few comments on your readme #3

odrotbohm opened this issue Dec 4, 2021 · 0 comments

Comments

@odrotbohm
Copy link

The biggest problem for JPA providers seems to be that records do not have a default constructor.

The opposite is true: the problem is that JPA requires default constructors (as you realize below).

If JPA providers could add some flexibility in how objects are instantiated/initialized, records could easily be supported. Supporting initialization through non-default constructors could also be beneficial for Object-Oriented Design: entities could have a single constructor and fields could be made final (JPA could even infer that @Column.updatable = false for final fields).

That's a slightly misguided perception. Why should a final field not be updatable? Immutability, on the object level, doesn't mean read-only column in the database. It's perfectly valid to want to stick with an immutable domain model, create new instances using "wither" methods, and persist those to fresh instances as updates to a row in the database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant