Code review comment: I'm not sure why `H2Database 1.x` is `2`. At least `4` is reasonable according to the processing logic of `H2Database 2.x`, I don't know what I overlooked.

Code before review:
public void assertAddOnDuplicateKey() throws SQLException {
int itemId = 1;
int userId1 = 101;
int userId2 = 102;
int orderId = 200;
String status = "init";
String updatedStatus = "updated on duplicate key";
try (
Connection connection = getShardingSphereDataSource().getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(INSERT_ON_DUPLICATE_KEY_SQL);
PreparedStatement queryStatement = connection.prepareStatement(SELECT_SQL_WITH_PARAMETER_MARKER_RETURN_STATUS)) {
preparedStatement.setInt(1, itemId);
preparedStatement.setInt(2, orderId);
preparedStatement.setInt(3, userId1);
preparedStatement.setString(4, status);
preparedStatement.setInt(5, itemId);
preparedStatement.setInt(6, orderId);
preparedStatement.setInt(7, userId2);
preparedStatement.setString(8, status);
preparedStatement.setString(9, updatedStatus);
int result = preparedStatement.executeUpdate();
assertThat(result, is(2));
queryStatement.setInt(1, orderId);
queryStatement.setInt(2, userId1);
try (ResultSet resultSet = queryStatement.executeQuery()) {
assertTrue(resultSet.next());
assertThat(resultSet.getInt(2), is(userId1));
assertThat(resultSet.getString(3), is(status));
}
queryStatement.setInt(1, orderId);
queryStatement.setInt(2, userId2);
try (ResultSet resultSet = queryStatement.executeQuery()) {
assertTrue(resultSet.next());
assertThat(resultSet.getInt(2), is(userId2));
assertThat(resultSet.getString(3), is(status));
}
}
try (
Connection connection = getShardingSphereDataSource().getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(INSERT_ON_DUPLICATE_KEY_SQL);
PreparedStatement queryStatement = connection.prepareStatement(SELECT_SQL_WITH_PARAMETER_MARKER_RETURN_STATUS)) {
preparedStatement.setInt(1, itemId);
preparedStatement.setInt(2, orderId);
preparedStatement.setInt(3, userId1);
preparedStatement.setString(4, status);
preparedStatement.setInt(5, itemId);
preparedStatement.setInt(6, orderId);
preparedStatement.setInt(7, userId2);
preparedStatement.setString(8, status);
preparedStatement.setString(9, updatedStatus);
int result = preparedStatement.executeUpdate();
assertThat(result, is(4));
queryStatement.setInt(1, orderId);
queryStatement.setInt(2, userId1);
try (ResultSet resultSet = queryStatement.executeQuery()) {
assertTrue(resultSet.next());
assertThat(resultSet.getInt(2), is(userId1));
assertThat(resultSet.getString(3), is(updatedStatus));
}
queryStatement.setInt(1, orderId);
queryStatement.setInt(2, userId2);
try (ResultSet resultSet = queryStatement.executeQuery()) {
assertTrue(resultSet.next());
assertThat(resultSet.getInt(2), is(userId2));
assertThat(resultSet.getString(3), is(updatedStatus));
}
}
}

Line under review: assertThat(result, is(4));

Code after addressing the review:
public void assertAddOnDuplicateKey() throws SQLException {
int itemId = 1;
int userId1 = 101;
int userId2 = 102;
int orderId = 200;
String status = "init";
String updatedStatus = "updated on duplicate key";
try (
Connection connection = getShardingSphereDataSource().getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(INSERT_ON_DUPLICATE_KEY_SQL);
PreparedStatement queryStatement = connection.prepareStatement(SELECT_SQL_WITH_PARAMETER_MARKER_RETURN_STATUS)) {
preparedStatement.setInt(1, itemId);
preparedStatement.setInt(2, orderId);
preparedStatement.setInt(3, userId1);
preparedStatement.setString(4, status);
preparedStatement.setInt(5, itemId);
preparedStatement.setInt(6, orderId);
preparedStatement.setInt(7, userId2);
preparedStatement.setString(8, status);
preparedStatement.setString(9, updatedStatus);
int result = preparedStatement.executeUpdate();
assertThat(result, is(2));
queryStatement.setInt(1, orderId);
queryStatement.setInt(2, userId1);
try (ResultSet resultSet = queryStatement.executeQuery()) {
assertTrue(resultSet.next());
assertThat(resultSet.getInt(2), is(userId1));
assertThat(resultSet.getString(3), is(status));
}
queryStatement.setInt(1, orderId);
queryStatement.setInt(2, userId2);
try (ResultSet resultSet = queryStatement.executeQuery()) {
assertTrue(resultSet.next());
assertThat(resultSet.getInt(2), is(userId2));
assertThat(resultSet.getString(3), is(status));
}
}
try (
Connection connection = getShardingSphereDataSource().getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(INSERT_ON_DUPLICATE_KEY_SQL);
PreparedStatement queryStatement = connection.prepareStatement(SELECT_SQL_WITH_PARAMETER_MARKER_RETURN_STATUS)) {
preparedStatement.setInt(1, itemId);
preparedStatement.setInt(2, orderId);
preparedStatement.setInt(3, userId1);
preparedStatement.setString(4, status);
preparedStatement.setInt(5, itemId);
preparedStatement.setInt(6, orderId);
preparedStatement.setInt(7, userId2);
preparedStatement.setString(8, status);
preparedStatement.setString(9, updatedStatus);
int result = preparedStatement.executeUpdate();
assertThat(result, is(4));
queryStatement.setInt(1, orderId);
queryStatement.setInt(2, userId1);
try (ResultSet resultSet = queryStatement.executeQuery()) {
assertTrue(resultSet.next());
assertThat(resultSet.getInt(2), is(userId1));
assertThat(resultSet.getString(3), is(updatedStatus));
}
queryStatement.setInt(1, orderId);
queryStatement.setInt(2, userId2);
try (ResultSet resultSet = queryStatement.executeQuery()) {
assertTrue(resultSet.next());
assertThat(resultSet.getInt(2), is(userId2));
assertThat(resultSet.getString(3), is(updatedStatus));
}
}
}