在我的应用程序中,当提出违规密钥时,我想获得约束名称,但我找不到任何获取此信息的方法. “getMessage()”返回的消息非常概括,我需要有关错误的更多信息,以便向最终用户发出可自定义的错误消息.
堆栈跟踪:
84732 [http-8080-1] WARN org.hibernate.util.JDBCExceptionReporter - sql Error: 0,sqlState: 23505
84732 [http-8080-1] ERROR org.hibernate.util.JDBCExceptionReporter - ERROR: duplicate key value violates unique constraint "ix_tb_oferta_vaga"
Detalhe: Key (cd_pj,cd_curso)=(680,29) already exists.
187405 [http-8080-1] WARN org.hibernate.util.JDBCExceptionReporter - sql Error: 0,sqlState: 23505
187405 [http-8080-1] ERROR org.hibernate.util.JDBCExceptionReporter - ERROR: duplicate key value violates unique constraint "ix_tb_oferta_vaga"
Detalhe: Key (cd_pj,29) already exists.
getMessage():
could not insert: [br.gov.ce.seduc.estagio.model.bean.OfertaVaga]; nested exception is org.hibernate.exception.ConstraintViolationException: could not insert: [br.gov.ce.seduc.estagio.model.bean.OfertaVaga]
谢谢.
亚瑟
最佳答案