I’m using Hibernate JPA and Spring in my project. Suppose if I try to insert a record with duplicate key value, the insert query will throw an exception.
Now, is it possible to get the table name, field name and possible cause for the exception from the SQL Exception object at run time !?
As the other answers have mentioned, most of the time you are limited to what you are given by the database. However in some cases Hibernate can tell you the problem – it won’t be the table and field, but can be the entity and property
For example if you try to put too large a value in a column you can use this: