com.avaje.ebean.config.dbplatform
Class SimpleSequenceIdGenerator

java.lang.Object
  extended by com.avaje.ebean.config.dbplatform.SimpleSequenceIdGenerator
All Implemented Interfaces:
IdGenerator

public class SimpleSequenceIdGenerator
extends Object

    
implements IdGenerator

    

A very simple Database sequence based IdGenerator.

One which batch requests sequence Id's would be better for performance.


Field Summary
 
Fields inherited from interface com.avaje.ebean.config.dbplatform.IdGenerator
AUTO_UUID
 
Constructor Summary
SimpleSequenceIdGenerator(DataSource dataSource, String sql, String seqName)
          Construct given a dataSource and sql to return the next sequence value.
 
Method Summary
 String getName()
          Return the name of the IdGenerator.
 boolean isDbSequence()
          Return true if this is a DB sequence.
 Object nextId()
          return the next unique identity value.
 void preAllocateIds(int batchSize)
          Is called prior to inserting OneToMany's as an indication that a number of beans are likely to need id's shortly.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleSequenceIdGenerator

public SimpleSequenceIdGenerator(DataSource dataSource,
                                 String sql,
                                 String seqName)
Construct given a dataSource and sql to return the next sequence value.

Method Detail

getName

public String getName()
Description copied from interface: IdGenerator
Return the name of the IdGenerator. For sequences this is the sequence name.

Specified by:
getName in interface IdGenerator

isDbSequence

public boolean isDbSequence()
Description copied from interface: IdGenerator
Return true if this is a DB sequence.

Specified by:
isDbSequence in interface IdGenerator

preAllocateIds

public void preAllocateIds(int batchSize)
Description copied from interface: IdGenerator
Is called prior to inserting OneToMany's as an indication that a number of beans are likely to need id's shortly.

Can be used as a performance optimisation to prefetch a number of Id's. Especially when the allocateSize is very large.

Specified by:
preAllocateIds in interface IdGenerator

nextId

public Object nextId()
Description copied from interface: IdGenerator
return the next unique identity value.

Specified by:
nextId in interface IdGenerator


Copyright © 2010. All Rights Reserved.