February 2018
Intermediate to advanced
406 pages
9h 55m
English
A few errors can be caught at the entity level, if they are not allowed. For example, not providing a product description when we have annotated the Product entity as follows:
@Column(nullable = false) private String name ;
This will cause the error message while trying to save the product supplied in the request without the name, for example, {"id":1, "catId":1}.
The server returns a 500 internal server error and gives a detailed message as follows:
could not execute statement; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException:
This is not a very clean message to return to the client. Therefore, it is better to catch the validations upfront and return a 400 error code ...
Read now
Unlock full access