While performing Spring MVC + Hibernate validation, the ValueObject is creating a problem. I am not allowed to use my Entity Objects directly in controller, so the ValueObject is created for each entity.
But now I need validation, in which I need to map @Valid
annotation directly to Entity from my controller, which I am not allowed. So, I need to validate my Entity using ValueObject.
Here's my controller method:
@RequestMapping(value = "/saveOperatorDetails", method = RequestMethod.POST)
public String saveOperatorDetails(@ModelAttribute("operatorDetails") @Valid OperatorVO operatorVO, BindingResult result) {
if (result.hasErrors()) {
return "admin.operator.registeroperator";
}
}
Now, if I use my Entity, Operator
my validation is a success.
But the ValueObjec(VO) can't validate the Hibernate Entity directly. Now what do I do to map ValueObject
with Entity
.