I would 开发者_开发问答like to be able to extract the entity and property from the ConstraintViolationException message in a rdbms neutral way... Can this be done ? if so how ?
Look into the hibernate source code: org.hibernate.exception.SQLStateConverter translates the SQLException.SQLState into the appropriate hibernate exception. SQLState is the only vendor-independent normalized data you have to find out the error cause. Java API documents it can follow one of two standards for error codes and messages... but there is no standard for specifying error detail.
So I think no, it can't be done, unless you have all rdbms at hand to test and interpret the error message strings yourself.
精彩评论