org.apache.openjpa.jdbc.kernel
Class AbstractJDBCSeq

java.lang.Object
  extended by org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq
All Implemented Interfaces:
JDBCSeq, org.apache.openjpa.kernel.Seq, org.apache.openjpa.lib.util.Closeable
Direct Known Subclasses:
NativeJDBCSeq, TableJDBCSeq

public abstract class AbstractJDBCSeq
extends java.lang.Object
implements JDBCSeq

Abstract sequence implementation. Handles obtaining the proper connection to used based on whether the sequence is transactional and whether a second datasource is configured.

Author:
Abe White

Field Summary
protected  java.lang.Object current
           
protected  int type
           
 
Fields inherited from interface org.apache.openjpa.kernel.Seq
TYPE_CONTIGUOUS, TYPE_DEFAULT, TYPE_NONTRANSACTIONAL, TYPE_TRANSACTIONAL
 
Constructor Summary
AbstractJDBCSeq()
           
 
Method Summary
 void addSchema(ClassMapping mapping, SchemaGroup group)
          No-op.
 void allocate(int additional, org.apache.openjpa.kernel.StoreContext ctx, org.apache.openjpa.meta.ClassMetaData meta)
           
protected  void allocateInternal(int additional, JDBCStore store, ClassMapping mapping)
          Allocate additional sequence values.
 void close()
          No-op.
protected  void closeConnection()
          Close the current connection.
 java.lang.Object current(org.apache.openjpa.kernel.StoreContext ctx, org.apache.openjpa.meta.ClassMetaData meta)
           
protected  java.lang.Object currentInternal(JDBCStore store, ClassMapping mapping)
          Return the current sequence object.
protected  java.sql.Connection getConnection(JDBCStore store)
          Return the connection to use based on the type of sequence.
 java.lang.Object next(org.apache.openjpa.kernel.StoreContext ctx, org.apache.openjpa.meta.ClassMetaData meta)
           
protected abstract  java.lang.Object nextInternal(JDBCStore store, ClassMapping mapping)
          Return the next sequence object.
 void setType(int type)
          Records the sequence type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

protected int type

current

protected java.lang.Object current
Constructor Detail

AbstractJDBCSeq

public AbstractJDBCSeq()
Method Detail

setType

public void setType(int type)
Records the sequence type.

Specified by:
setType in interface org.apache.openjpa.kernel.Seq

next

public java.lang.Object next(org.apache.openjpa.kernel.StoreContext ctx,
                             org.apache.openjpa.meta.ClassMetaData meta)
Specified by:
next in interface org.apache.openjpa.kernel.Seq

current

public java.lang.Object current(org.apache.openjpa.kernel.StoreContext ctx,
                                org.apache.openjpa.meta.ClassMetaData meta)
Specified by:
current in interface org.apache.openjpa.kernel.Seq

allocate

public void allocate(int additional,
                     org.apache.openjpa.kernel.StoreContext ctx,
                     org.apache.openjpa.meta.ClassMetaData meta)
Specified by:
allocate in interface org.apache.openjpa.kernel.Seq

addSchema

public void addSchema(ClassMapping mapping,
                      SchemaGroup group)
No-op.

Specified by:
addSchema in interface JDBCSeq

close

public void close()
No-op.

Specified by:
close in interface org.apache.openjpa.kernel.Seq
Specified by:
close in interface org.apache.openjpa.lib.util.Closeable

nextInternal

protected abstract java.lang.Object nextInternal(JDBCStore store,
                                                 ClassMapping mapping)
                                          throws java.lang.Exception
Return the next sequence object.

Throws:
java.lang.Exception

currentInternal

protected java.lang.Object currentInternal(JDBCStore store,
                                           ClassMapping mapping)
                                    throws java.lang.Exception
Return the current sequence object. By default returns the last sequence value used, or null if no sequence values have been requested yet.

Throws:
java.lang.Exception

allocateInternal

protected void allocateInternal(int additional,
                                JDBCStore store,
                                ClassMapping mapping)
                         throws java.lang.Exception
Allocate additional sequence values. Does nothing by default.

Throws:
java.lang.Exception

getConnection

protected java.sql.Connection getConnection(JDBCStore store)
                                     throws java.sql.SQLException
Return the connection to use based on the type of sequence. This connection will automatically be closed; do not close it.

Throws:
java.sql.SQLException

closeConnection

protected void closeConnection()
Close the current connection.



Copyright © 2006 Apache Software Foundation. All Rights Reserved.