@Test void testIsDuplicateKey_isDuplicateKey_usingNonNullSqlState() { Properties props = new Properties(); props.setProperty("MyCustom_Database_Engine.duplicateKeyCodes", "-104"); String databaseProductName = "MyCustom Database Engine"; SQLErrorCodesResolver sqlErrorCodesResolver = new SQLErrorCodesResolver(props, databaseProductName); SQLException sqlException = new SQLException("test", (String) null); boolean isDuplicateKey = sqlErrorCodesResolver.isDuplicateKeyViolation(new PersistenceException("error", sqlException)); assertFalse(isDuplicateKey); }
@Override public boolean isDuplicateKeyViolation(Exception exception) { return causeIsEntityExistsException(exception) || findException(exception, SQLException.class) .map(sqlException -> isDuplicateKeyCode(sqlException, duplicateKeyCodes)).orElse(false); }
SQLErrorCodesResolver implements PersistenceExceptionResolver { @Override public boolean isDuplicateKeyViolation(Exception exception) { return causeIsEntityExistsException(exception) || findException(exception, SQLException.class) .map(sqlException -> isDuplicateKeyCode(sqlException, duplicateKeyCodes)).orElse(false); } }
SQLErrorCodesResolver implements PersistenceExceptionResolver { @Override public boolean isDuplicateKeyViolation(Exception exception) { return causeIsEntityExistsException(exception) || findException(exception, SQLException.class) .map(sqlException -> isDuplicateKeyCode(sqlException, duplicateKeyCodes)).orElse(false); } SQLErrorCodesResolver(List<Integer> duplicateKeyCodes);  SQLErrorCodesResolver(DataSource dataSource);  SQLErrorCodesResolver(String databaseProductName);  SQLErrorCodesResolver(Properties properties, String databaseProductName);  SQLErrorCodesResolver(Properties properties, DataSource dataSource); }
SQLErrorCodesResolver implements PersistenceExceptionResolver { @Override public boolean isDuplicateKeyViolation(Exception exception) { return causeIsEntityExistsException(exception) || findException(exception, SQLException.class) .map(sqlException -> isDuplicateKeyCode(sqlException, duplicateKeyCodes)).orElse(false); } SQLErrorCodesResolver(List<Integer> duplicateKeyCodes);  SQLErrorCodesResolver(DataSource dataSource);  SQLErrorCodesResolver(String databaseProductName);  SQLErrorCodesResolver(Properties properties, String databaseProductName);  SQLErrorCodesResolver(Properties properties, DataSource dataSource); @Override boolean isDuplicateKeyViolation(Exception exception); }
SQLErrorCodesResolver implements PersistenceExceptionResolver { @Override public boolean isDuplicateKeyViolation(Exception exception) { return causeIsEntityExistsException(exception) || findException(exception, SQLException.class) .map(sqlException -> isDuplicateKeyCode(sqlException, duplicateKeyCodes)).orElse(false); } SQLErrorCodesResolver(List<Integer> duplicateKeyCodes);  SQLErrorCodesResolver(DataSource dataSource);  SQLErrorCodesResolver(String databaseProductName);  SQLErrorCodesResolver(Properties properties, String databaseProductName);  SQLErrorCodesResolver(Properties properties, DataSource dataSource); @Override boolean isDuplicateKeyViolation(Exception exception);  }