I'm trying to inject data into database based on form input but i'm facing a nasty exception and I can't seem to be able to wrap my head around a scalable solution and I have tried many... Maybe you can help? How can I find the needle in this haystack?
It's very hard to pinpoint with so many attributes! I tried to remove @NotNull from every class but the exception remains no matter what I try... I also changed persistence.xml to value="None" to turn it off but it was a bad idea as expected and it didn't help.
at controller.ControllerServlet.doPost(ControllerServlet.java:409) refers to code:
at session.OrderManager.addCustomer(OrderManager.java:55) refers to code:
at session.OrderManager.placeOrder(OrderManager.java:34) refers to code:
Wrap the code in OrderManager.addCustomer in a try-catch block, catch any ConstraintViolationException, log it and its violation, and rethrow:
If that still doesn't give you enough information, log each separate constraint violation, especially the message and property path.
I had a constraint violated on my model that was detected before persisting to the datastore. This meant that my Customer or related entities had a Validation (eg. @NotNull, @Size) that was not honored.
Removing every @NotNull annotation in my database and making sure the length of the form input did respect the database columns @Size or increasing it. Hope it can help you as well if you are seeing this!