Package org.springframework.jdbc.support.incrementer

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


                public Object processMetaData(DatabaseMetaData databaseMetaData) throws SQLException {
                    newPo.setUsingLowerCaseIdentifiers(databaseMetaData.storesLowerCaseIdentifiers());
                    newPo.setDatabaseProductName(databaseMetaData.getDatabaseProductName());
                    if ("PostgreSQL".equals(newPo.getDatabaseProductName())) {
                        newPo.setUsingGeneratedKeysStrategy(false);
                        newPo.setIncrementer(new PostgreSQLSequenceMaxValueIncrementer(dataSource, newPo.getBaseName() + "_seq"));
                    }
                    else if ("HSQL Database Engine".equals(newPo.getDatabaseProductName())) {
                        newPo.setUsingGeneratedKeysStrategy(false);
                        newPo.setIncrementer(new HsqlMaxValueIncrementer(dataSource, newPo.getBaseName() + "_seq", "value"));
                    }
View Full Code Here


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

    PostgreSQLSequenceMaxValueIncrementer incrementer = new PostgreSQLSequenceMaxValueIncrementer();
    incrementer.setDataSource(ds);
    incrementer.setIncrementerName("myseq");
    incrementer.setPaddingLength(5);
    incrementer.afterPropertiesSet();

    assertEquals("00010", incrementer.nextStringValue());
    assertEquals(12, incrementer.nextIntValue());

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

          pkValue = incr.nextLongValue();
        }catch (Exception e) {
          logger.error(e,e);
        }
      }else if(StringUtil.isNotEmpty(dbType)&&"postgres".equalsIgnoreCase(dbType)){
        PostgreSQLSequenceMaxValueIncrementer incr = new PostgreSQLSequenceMaxValueIncrementer(dataSource, "HIBERNATE_SEQUENCE")
        try{
          pkValue = incr.nextLongValue();
        }catch (Exception e) {
          logger.error(e,e);
        }
      }else{
        pkValue = null;
      }
    }else if(StringUtil.isNotEmpty(pkType)&&"SEQUENCE".equalsIgnoreCase(pkType)){
      if(StringUtil.isNotEmpty(dbType)&&"oracle".equalsIgnoreCase(dbType)){
        OracleSequenceMaxValueIncrementer incr = new OracleSequenceMaxValueIncrementer(dataSource, pkSequence)
        try{
          pkValue = incr.nextLongValue();
        }catch (Exception e) {
          logger.error(e,e);
        }
      }else if(StringUtil.isNotEmpty(dbType)&&"postgres".equalsIgnoreCase(dbType)){
        PostgreSQLSequenceMaxValueIncrementer incr = new PostgreSQLSequenceMaxValueIncrementer(dataSource, pkSequence)
        try{
          pkValue = incr.nextLongValue();
        }catch (Exception e) {
          logger.error(e,e);
        }
      }else{
        pkValue = null;
View Full Code Here

    given(connection.createStatement()).willReturn(statement);
    given(statement.executeQuery("select nextval('myseq')")).willReturn(resultSet);
    given(resultSet.next()).willReturn(true);
    given(resultSet.getLong(1)).willReturn(10L, 12L);

    PostgreSQLSequenceMaxValueIncrementer incrementer = new PostgreSQLSequenceMaxValueIncrementer();
    incrementer.setDataSource(dataSource);
    incrementer.setIncrementerName("myseq");
    incrementer.setPaddingLength(5);
    incrementer.afterPropertiesSet();

    assertEquals("00010", incrementer.nextStringValue());
    assertEquals(12, incrementer.nextIntValue());

    verify(resultSet, times(2)).close();
    verify(statement, times(2)).close();
    verify(connection, times(2)).close();
  }
View Full Code Here

    }
    else if (databaseType == ORACLE) {
      return new OracleSequenceMaxValueIncrementer(dataSource, incrementerName);
    }
    else if (databaseType == POSTGRES) {
      return new PostgreSQLSequenceMaxValueIncrementer(dataSource, incrementerName);
    }
    else if (databaseType == SQLITE) {
      return new SqliteMaxValueIncrementer(dataSource, incrementerName, incrementerColumnName);
    }
    else if (databaseType == SQLSERVER) {
View Full Code Here

TOP

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

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.