开发者

How to extract actual entity and property name that is a duplicate from Hibernate ConstraintViolationException

开发者 https://www.devze.com 2023-01-02 21:03 出处:网络
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 s

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消