@@ -584,26 +584,35 @@ public boolean supportsValuesListForInsert() {
584584
585585 @ Override
586586 public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate () {
587- return (sqlException , message , sql ) ->
588- switch ( extractErrorCode ( sqlException ) ) {
589- case -378 , -233 , -107 , -113 , -134 , -143 , -144 , -154 ->
590- //TODO: which of these are these are really LockTimeoutExceptions
591- // rather than the more generic LockAcquisitionException?
592- new LockAcquisitionException ( message , sqlException , sql );
593- case -239 , -268 ->
594- new ConstraintViolationException ( message , sqlException , sql , ConstraintViolationException .ConstraintKind .UNIQUE ,
595- getViolatedConstraintNameExtractor ().extractConstraintName ( sqlException ) );
596- case -691 , -692 ->
597- new ConstraintViolationException ( message , sqlException , sql , ConstraintViolationException .ConstraintKind .FOREIGN_KEY ,
598- getViolatedConstraintNameExtractor ().extractConstraintName ( sqlException ) );
599- case -703 , -391 ->
600- new ConstraintViolationException ( message , sqlException , sql , ConstraintViolationException .ConstraintKind .NOT_NULL ,
601- getViolatedConstraintNameExtractor ().extractConstraintName ( sqlException ) );
602- case -530 ->
603- new ConstraintViolationException ( message , sqlException , sql , ConstraintViolationException .ConstraintKind .CHECK ,
604- getViolatedConstraintNameExtractor ().extractConstraintName ( sqlException ) );
605- default -> null ;
606- };
587+ return (exception , message , sql ) -> switch ( extractErrorCode ( exception ) ) {
588+ case -239 , -268 ->
589+ new ConstraintViolationException ( message , exception , sql , ConstraintViolationException .ConstraintKind .UNIQUE ,
590+ getViolatedConstraintNameExtractor ().extractConstraintName ( exception ) );
591+ case -691 , -692 ->
592+ new ConstraintViolationException ( message , exception , sql , ConstraintViolationException .ConstraintKind .FOREIGN_KEY ,
593+ getViolatedConstraintNameExtractor ().extractConstraintName ( exception ) );
594+ case -703 , -391 ->
595+ new ConstraintViolationException ( message , exception , sql , ConstraintViolationException .ConstraintKind .NOT_NULL ,
596+ getViolatedConstraintNameExtractor ().extractConstraintName ( exception ) );
597+ case -530 ->
598+ new ConstraintViolationException ( message , exception , sql , ConstraintViolationException .ConstraintKind .CHECK ,
599+ getViolatedConstraintNameExtractor ().extractConstraintName ( exception ) );
600+ default -> {
601+ // unwrap the ISAM error, if any
602+ if ( exception .getCause () instanceof SQLException cause && cause != exception ) {
603+ yield switch ( extractErrorCode ( cause ) ) {
604+ case -107 , -113 , -134 , -143 , -144 , -154 ->
605+ //TODO: which of these are these are really LockTimeoutExceptions
606+ // rather than the more generic LockAcquisitionException?
607+ new LockAcquisitionException ( message , exception , sql );
608+ default -> null ;
609+ };
610+ }
611+ else {
612+ yield null ;
613+ }
614+ }
615+ };
607616 }
608617
609618 @ Override
0 commit comments