From 20ad230f6d106a954dd4b00ae3e5f45ca90c5fd0 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Fri, 24 Jul 2020 07:51:00 +0100 Subject: [PATCH] Fix compilation error after merge --- .../src/main/java/org/hibernate/dialect/H2Dialect.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java index 85f7569c04..1cb4757ae1 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java @@ -267,19 +267,20 @@ public class H2Dialect extends Dialect { private static final ViolatedConstraintNameExtractor EXTRACTOR = new TemplatedViolatedConstraintNameExtractor( sqle -> { + String constraintName = null; // 23000: Check constraint violation: {0} // 23001: Unique index or primary key violation: {0} if ( sqle.getSQLState().startsWith( "23" ) ) { final String message = sqle.getMessage(); final int idx = message.indexOf( "violation: " ); if ( idx > 0 ) { - return message.substring( idx + "violation: ".length() ); + constraintName = message.substring( idx + "violation: ".length() ); } - if ( sqle.getSQLState().equals("23506") ) { - return constraintName.substring( 1, constraintName.indexOf(":") ); + if ( sqle.getSQLState().equals( "23506" ) ) { + constraintName = constraintName.substring( 1, constraintName.indexOf( ":" ) ); } } - return null; + return constraintName; } ); @Override