Java Code Examples for org.springframework.jdbc.support.incrementer.OracleSequenceMaxValueIncrementer

The following examples show how to use org.springframework.jdbc.support.incrementer.OracleSequenceMaxValueIncrementer. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Test
public void testOracleSequenceMaxValueIncrementer() throws SQLException {
	given(dataSource.getConnection()).willReturn(connection);
	given(connection.createStatement()).willReturn(statement);
	given(statement.executeQuery("select myseq.nextval from dual")).willReturn(resultSet);
	given(resultSet.next()).willReturn(true);
	given(resultSet.getLong(1)).willReturn(10L, 12L);

	OracleSequenceMaxValueIncrementer incrementer = new OracleSequenceMaxValueIncrementer();
	incrementer.setDataSource(dataSource);
	incrementer.setIncrementerName("myseq");
	incrementer.setPaddingLength(2);
	incrementer.afterPropertiesSet();

	assertEquals(10, incrementer.nextLongValue());
	assertEquals("12", incrementer.nextStringValue());

	verify(resultSet, times(2)).close();
	verify(statement, times(2)).close();
	verify(connection, times(2)).close();
}
 
Example 2
@Test
public void testOracleSequenceMaxValueIncrementer() throws SQLException {
	given(dataSource.getConnection()).willReturn(connection);
	given(connection.createStatement()).willReturn(statement);
	given(statement.executeQuery("select myseq.nextval from dual")).willReturn(resultSet);
	given(resultSet.next()).willReturn(true);
	given(resultSet.getLong(1)).willReturn(10L, 12L);

	OracleSequenceMaxValueIncrementer incrementer = new OracleSequenceMaxValueIncrementer();
	incrementer.setDataSource(dataSource);
	incrementer.setIncrementerName("myseq");
	incrementer.setPaddingLength(2);
	incrementer.afterPropertiesSet();

	assertEquals(10, incrementer.nextLongValue());
	assertEquals("12", incrementer.nextStringValue());

	verify(resultSet, times(2)).close();
	verify(statement, times(2)).close();
	verify(connection, times(2)).close();
}
 
Example 3
@Test
public void testOracleSequenceMaxValueIncrementer() throws SQLException {
	given(dataSource.getConnection()).willReturn(connection);
	given(connection.createStatement()).willReturn(statement);
	given(statement.executeQuery("select myseq.nextval from dual")).willReturn(resultSet);
	given(resultSet.next()).willReturn(true);
	given(resultSet.getLong(1)).willReturn(10L, 12L);

	OracleSequenceMaxValueIncrementer incrementer = new OracleSequenceMaxValueIncrementer();
	incrementer.setDataSource(dataSource);
	incrementer.setIncrementerName("myseq");
	incrementer.setPaddingLength(2);
	incrementer.afterPropertiesSet();

	assertEquals(10, incrementer.nextLongValue());
	assertEquals("12", incrementer.nextStringValue());

	verify(resultSet, times(2)).close();
	verify(statement, times(2)).close();
	verify(connection, times(2)).close();
}
 
Example 4
@Test
public void testOracleSequenceMaxValueIncrementer() throws SQLException {
	given(dataSource.getConnection()).willReturn(connection);
	given(connection.createStatement()).willReturn(statement);
	given(statement.executeQuery("select myseq.nextval from dual")).willReturn(resultSet);
	given(resultSet.next()).willReturn(true);
	given(resultSet.getLong(1)).willReturn(10L, 12L);

	OracleSequenceMaxValueIncrementer incrementer = new OracleSequenceMaxValueIncrementer();
	incrementer.setDataSource(dataSource);
	incrementer.setIncrementerName("myseq");
	incrementer.setPaddingLength(2);
	incrementer.afterPropertiesSet();

	assertEquals(10, incrementer.nextLongValue());
	assertEquals("12", incrementer.nextStringValue());

	verify(resultSet, times(2)).close();
	verify(statement, times(2)).close();
	verify(connection, times(2)).close();
}
 
Example 5
@Test
public void testGetIncrementer_Oracle() throws Exception {
    DataFieldMaxValueIncrementer incrementer = MaxValueIncrementerFactory.getIncrementer(oracle, "MY_SEQUENCE");
    assertTrue(incrementer instanceof OracleSequenceMaxValueIncrementer);
    OracleSequenceMaxValueIncrementer oracleIncrementer = (OracleSequenceMaxValueIncrementer)incrementer;
    assertEquals("MY_SEQUENCE", oracleIncrementer.getIncrementerName());

    // ensure that it's caching the incrementer
    assertSame(incrementer, MaxValueIncrementerFactory.getIncrementer(oracle, "MY_SEQUENCE"));
    // ensure that different sequence gives a different incrementer
    assertNotSame(incrementer, MaxValueIncrementerFactory.getIncrementer(oracle, "MY_SEQUENCE_2"));

}
 
Example 6
Source Project: nextreports-server   Source File: OracleAuditor.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public int getNextEventId() {
	return new OracleSequenceMaxValueIncrementer(getDataSource(), "NS_AUDIT_SEQ").nextIntValue();
}