com.avaje.ebean.config.dbplatform
Class SequenceIdGenerator

java.lang.Object
  extended by com.avaje.ebean.config.dbplatform.SequenceIdGenerator
All Implemented Interfaces:
IdGenerator
Direct Known Subclasses:
DB2SequenceIdGenerator, H2SequenceIdGenerator, OracleSequenceIdGenerator, PostgresSequenceIdGenerator

public abstract class SequenceIdGenerator
extends Object

    
implements IdGenerator

    

Database sequence based IdGenerator.


Field Summary
 
Fields inherited from interface com.avaje.ebean.config.dbplatform.IdGenerator
AUTO_UUID
 
Constructor Summary
SequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int batchSize)
          Construct given a dataSource and sql to return the next sequence value.
 
Method Summary
 String getName()
          Returns the sequence name.
abstract  String getSql(int batchSize)
           
 boolean isDbSequence()
          Returns true.
 Object nextId()
          Return the next Id.
 void preAllocateIds(int allocateSize)
          If allocateSize is large load some sequences in a background thread.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SequenceIdGenerator

public SequenceIdGenerator(BackgroundExecutor be,
                           DataSource ds,
                           String seqName,
                           int batchSize)
Construct given a dataSource and sql to return the next sequence value.

Method Detail

getSql

public abstract String getSql(int batchSize)

getName

public String getName()
Returns the sequence name.

Specified by:
getName in interface IdGenerator

isDbSequence

public boolean isDbSequence()
Returns true.

Specified by:
isDbSequence in interface IdGenerator

preAllocateIds

public void preAllocateIds(int allocateSize)
If allocateSize is large load some sequences in a background thread.

For example, when inserting a bean with a cascade on a OneToMany with many beans Ebean can call this to ensure .

Specified by:
preAllocateIds in interface IdGenerator

nextId

public Object nextId()
Return the next Id.

Specified by:
nextId in interface IdGenerator


Copyright © 2010. All Rights Reserved.