Package org.apache.openjpa.jdbc.kernel
Class AbstractJDBCSeq
- java.lang.Object
- 
- org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq
 
- 
- 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 SummaryFields Modifier and Type Field Description protected java.lang.Objectcurrentprotected inttype- 
Fields inherited from interface org.apache.openjpa.kernel.SeqTYPE_CONTIGUOUS, TYPE_DEFAULT, TYPE_NONTRANSACTIONAL, TYPE_TRANSACTIONAL
 
- 
 - 
Constructor SummaryConstructors Constructor Description AbstractJDBCSeq()
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddSchema(ClassMapping mapping, SchemaGroup group)No-op.voidallocate(int additional, StoreContext ctx, ClassMetaData meta)Allocate additional values efficiently.protected voidallocateInternal(int additional, JDBCStore store, ClassMapping mapping)Allocate additional sequence values.voidclose()No-op.protected voidcloseConnection(java.sql.Connection conn)Close the current connection.java.lang.Objectcurrent(StoreContext ctx, ClassMetaData meta)Return the current value of the sequence, or null if not available.protected java.lang.ObjectcurrentInternal(JDBCStore store, ClassMapping mapping)Return the current sequence object.abstract JDBCConfigurationgetConfiguration()Return theJDBCConfigurationfor this sequence.protected java.sql.ConnectiongetConnection(JDBCStore store)protected java.sql.ConnectiongetConnection(JDBCStore store, boolean forceNewConnection)Return the connection to use based on the type of sequence.java.lang.Objectnext(StoreContext ctx, ClassMetaData meta)Return the next value in the sequence.protected abstract java.lang.ObjectnextInternal(JDBCStore store, ClassMapping mapping)Return the next sequence object.voidsetType(int type)Records the sequence type.protected booleansuspendInJTA()Detect whether or not OpenJPA should suspend the transaction in a managed environment.
 
- 
- 
- 
Method Detail- 
setTypepublic void setType(int type) Records the sequence type.
 - 
nextpublic java.lang.Object next(StoreContext ctx, ClassMetaData meta) Description copied from interface:SeqReturn the next value in the sequence.
 - 
currentpublic java.lang.Object current(StoreContext ctx, ClassMetaData meta) Description copied from interface:SeqReturn the current value of the sequence, or null if not available.
 - 
allocatepublic void allocate(int additional, StoreContext ctx, ClassMetaData meta)Description copied from interface:SeqAllocate additional values efficiently.
 - 
addSchemapublic void addSchema(ClassMapping mapping, SchemaGroup group) No-op.
 - 
closepublic void close() No-op.
 - 
nextInternalprotected abstract java.lang.Object nextInternal(JDBCStore store, ClassMapping mapping) throws java.lang.Exception Return the next sequence object.- Throws:
- java.lang.Exception
 
 - 
getConfigurationpublic abstract JDBCConfiguration getConfiguration() Return theJDBCConfigurationfor this sequence.
 - 
currentInternalprotected 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. Default implementation is not threadsafe.- Throws:
- java.lang.Exception
 
 - 
allocateInternalprotected void allocateInternal(int additional, JDBCStore store, ClassMapping mapping) throws java.lang.ExceptionAllocate additional sequence values. Does nothing by default.- Throws:
- java.lang.Exception
 
 - 
getConnectionprotected java.sql.Connection getConnection(JDBCStore store) throws java.sql.SQLException - Throws:
- java.sql.SQLException
- See Also:
- but without forcing a connection.
 
 - 
getConnectionprotected java.sql.Connection getConnection(JDBCStore store, boolean forceNewConnection) 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. - Parameters:
- forceNewConnection- if- truea new connection will be forced
- Returns:
- If the sequence type is TYPE_TRANSACTIONALorTYPE_CONTIGUOUSthe connection from theStoreManagerwill be returned.Otherwise a new connection will be obtained using DataSource2 from the current configuration. In this case autocommit is set to false prior to returning the connection. 
- Throws:
- java.sql.SQLException
 
 - 
closeConnectionprotected void closeConnection(java.sql.Connection conn) Close the current connection. If the sequence isTYPE_TRANSACTIONALorTYPE_CONTIGUOUSwe will decrement the ref count. Otherwise the connection will be committed and then closed.
 - 
suspendInJTAprotected boolean suspendInJTA() Detect whether or not OpenJPA should suspend the transaction in a managed environment.
 
- 
 
-