Package org.springframework.jdbc.support.incrementer

Examples of org.springframework.jdbc.support.incrementer.MySQLMaxValueIncrementer


    dsControl.replay();
    conControl.replay();
    stmtControl.replay();
    rsControl.replay();

    MySQLMaxValueIncrementer incrementer = new MySQLMaxValueIncrementer();
    incrementer.setDataSource(ds);
    incrementer.setIncrementerName("myseq");
    incrementer.setColumnName("seq");
    incrementer.setCacheSize(2);
    incrementer.setPaddingLength(1);
    incrementer.afterPropertiesSet();

    assertEquals(1, incrementer.nextIntValue());
    assertEquals(2, incrementer.nextLongValue());
    assertEquals("3", incrementer.nextStringValue());
    assertEquals(4, incrementer.nextLongValue());

    dsControl.verify();
    conControl.verify();
    stmtControl.verify();
    rsControl.verify();
View Full Code Here


    given(connection.createStatement()).willReturn(statement);
    given(statement.executeQuery("select last_insert_id()")).willReturn(resultSet);
    given(resultSet.next()).willReturn(true);
    given(resultSet.getLong(1)).willReturn(2L, 4L);

    MySQLMaxValueIncrementer incrementer = new MySQLMaxValueIncrementer();
    incrementer.setDataSource(dataSource);
    incrementer.setIncrementerName("myseq");
    incrementer.setColumnName("seq");
    incrementer.setCacheSize(2);
    incrementer.setPaddingLength(1);
    incrementer.afterPropertiesSet();

    assertEquals(1, incrementer.nextIntValue());
    assertEquals(2, incrementer.nextLongValue());
    assertEquals("3", incrementer.nextStringValue());
    assertEquals(4, incrementer.nextLongValue());

    verify(statement, times(2)).executeUpdate("update myseq set seq = last_insert_id(seq + 2)");
    verify(resultSet, times(2)).close();
    verify(statement, times(2)).close();
    verify(connection, times(2)).close();
View Full Code Here

    }
    else if (databaseType == H2) {
      return new H2SequenceMaxValueIncrementer(dataSource, incrementerName);
    }
    else if (databaseType == MYSQL) {
      return new MySQLMaxValueIncrementer(dataSource, incrementerName, incrementerColumnName);
    }
    else if (databaseType == ORACLE) {
      return new OracleSequenceMaxValueIncrementer(dataSource, incrementerName);
    }
    else if (databaseType == POSTGRES) {
View Full Code Here

    this.setDataSource(ds);
    setIncrementer(this.getIncrementer(ds));
  }

  private DataFieldMaxValueIncrementer getIncrementer(DataSource ds) {
    MySQLMaxValueIncrementer incrementer = new MySQLMaxValueIncrementer();
    incrementer.setCacheSize(100);
    incrementer.setDataSource(ds);
    incrementer.setIncrementerName(getKeyspaceTableName());
    incrementer.setColumnName(COLUMN_NAME);
    return incrementer;
  }
View Full Code Here

TOP

Related Classes of org.springframework.jdbc.support.incrementer.MySQLMaxValueIncrementer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.