diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/incrementer/MariaDBSequenceMaxValueIncrementer.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/incrementer/MariaDBSequenceMaxValueIncrementer.java index f6cd6b5075..573ff894ca 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/incrementer/MariaDBSequenceMaxValueIncrementer.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/incrementer/MariaDBSequenceMaxValueIncrementer.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,11 +19,11 @@ package org.springframework.jdbc.support.incrementer; import javax.sql.DataSource; /** - * {@link DataFieldMaxValueIncrementer} that retrieves the next value - * of a given MariaDB sequence. + * {@link DataFieldMaxValueIncrementer} that retrieves the next value of a given + * MariaDB sequence. * * @author Mahmoud Ben Hassine - * @since 6.0.0 + * @since 6.0 */ public class MariaDBSequenceMaxValueIncrementer extends AbstractSequenceMaxValueIncrementer { diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/support/DataFieldMaxValueIncrementerTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/support/DataFieldMaxValueIncrementerTests.java index 7ba9881dd9..57b919f648 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/support/DataFieldMaxValueIncrementerTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/support/DataFieldMaxValueIncrementerTests.java @@ -168,6 +168,28 @@ class DataFieldMaxValueIncrementerTests { verify(connection, times(2)).close(); } + @Test + void mariaDBSequenceMaxValueIncrementer() throws SQLException { + given(dataSource.getConnection()).willReturn(connection); + given(connection.createStatement()).willReturn(statement); + given(statement.executeQuery("select next value for myseq")).willReturn(resultSet); + given(resultSet.next()).willReturn(true); + given(resultSet.getLong(1)).willReturn(10L, 12L); + + MariaDBSequenceMaxValueIncrementer incrementer = new MariaDBSequenceMaxValueIncrementer(); + incrementer.setDataSource(dataSource); + incrementer.setIncrementerName("myseq"); + incrementer.setPaddingLength(5); + incrementer.afterPropertiesSet(); + + assertThat(incrementer.nextStringValue()).isEqualTo("00010"); + assertThat(incrementer.nextIntValue()).isEqualTo(12); + + verify(resultSet, times(2)).close(); + verify(statement, times(2)).close(); + verify(connection, times(2)).close(); + } + @Test void oracleSequenceMaxValueIncrementer() throws SQLException { given(dataSource.getConnection()).willReturn(connection); @@ -212,26 +234,4 @@ class DataFieldMaxValueIncrementerTests { verify(connection, times(2)).close(); } - @Test - void mariaDBSequenceMaxValueIncrementer() throws SQLException { - given(dataSource.getConnection()).willReturn(connection); - given(connection.createStatement()).willReturn(statement); - given(statement.executeQuery("select next value for myseq")).willReturn(resultSet); - given(resultSet.next()).willReturn(true); - given(resultSet.getLong(1)).willReturn(10L, 12L); - - MariaDBSequenceMaxValueIncrementer incrementer = new MariaDBSequenceMaxValueIncrementer(); - incrementer.setDataSource(dataSource); - incrementer.setIncrementerName("myseq"); - incrementer.setPaddingLength(5); - incrementer.afterPropertiesSet(); - - assertThat(incrementer.nextStringValue()).isEqualTo("00010"); - assertThat(incrementer.nextIntValue()).isEqualTo(12); - - verify(resultSet, times(2)).close(); - verify(statement, times(2)).close(); - verify(connection, times(2)).close(); - } - }