001package io.ebean.config.dbplatform.oracle;
002
003import io.ebean.BackgroundExecutor;
004import io.ebean.config.dbplatform.SequenceBatchIdGenerator;
005
006import javax.sql.DataSource;
007
008/**
009 * Oracle specific sequence Id Generator.
010 */
011public class OracleSequenceIdGenerator extends SequenceBatchIdGenerator {
012
013  private final String baseSql;
014
015  /**
016   * Construct given a dataSource and sql to return the next sequence value.
017   */
018  public OracleSequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int batchSize) {
019    super(be, ds, seqName, batchSize);
020    this.baseSql = "select " + seqName + ".nextval, a from (select level as a FROM dual CONNECT BY level <= ";
021  }
022
023  @Override
024  public String getSql(int batchSize) {
025    return baseSql + batchSize + ")";
026  }
027}