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 javax.validation annotation with Validator for Repository Entity [DATAJDBC-482] #708
Comments
Jens Schauder commented Why should validation be tied to persistence? Shouldn't validation happen at the very beginning of any processing of input while persisting changes happens pretty much at the end?
|
MyeongHyeonLee commented In complex business processes, input data and persistent data can be different. AggregateRoot is responsible for the invarient of Aggregate.
I think Aggregate should check the invarient of the final state before it is persisted. In Spring Data there are features to change entity state inside repository. (EntityCallback, AuditAware ...)
I think the Repository needs validation of the change state on the EntityCallback before giving it persistence.
|
Jens Schauder commented
Exactly. But this issue asks to move it into the repository where it doesn't belong in my opinion |
MyeongHyeonLee commented Changed the Component in this issue to Does it match your request? Or was it another intension? |
Jens Schauder commented No my comment wasn't about the component field of Jira it was about where to put validation logic in an application. There is a very valid use case to put it on the boundary of the system. For example when data enters the system you probably want to validate it. This might be done through bean validation (Spring MVC has support for it https://spring.io/guides/gs/validating-form-input/) or as part of the implementation of an aggregate root as you stated yourself. But I don't think validating an object when persisting it in the database makes any sense in a well structured application. |
MyeongHyeonLee commented Thanks for the feedback. I will perform validation where I need it. I will close this issue. Thank you |
MyeongHyeonLee opened DATAJDBC-482 and commented
When an Entity is saved to a Repository, it would be nice to have a javax.validation annotation with the Validator. (like JPA BeanValidationEventListener)
https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationEventListener.java#L103
I have implemented Validation with EntityCallback.
However, it would be nice to apply it as a basic feature in Spring Data JDBC.
Please review the appropriateness of this proposal.
Affects: 2.0 M2 (Neumann)
The text was updated successfully, but these errors were encountered: