| Method from org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq Detail: |
public void addSchema(ClassMapping mapping,
SchemaGroup group) {
}
|
public void allocate(int additional,
StoreContext ctx,
ClassMetaData meta) {
JDBCStore store = getStore(ctx);
try {
allocateInternal(additional, store, (ClassMapping) meta);
} catch (OpenJPAException ke) {
throw ke;
} catch (SQLException se) {
throw SQLExceptions.getStore(se, store.getDBDictionary());
} catch (Exception e) {
throw new StoreException(e);
}
}
|
protected void allocateInternal(int additional,
JDBCStore store,
ClassMapping mapping) throws Exception {
}
Allocate additional sequence values. Does nothing by default. |
public void close() {
}
|
protected void closeConnection(Connection conn) {
if (conn == null)
return;
if (type == TYPE_TRANSACTIONAL || type == TYPE_CONTIGUOUS) {
// do nothing; this seq is part of the business transaction
return;
} else if (suspendInJTA()) {
try {
TransactionManager tm = getConfiguration()
.getManagedRuntimeInstance().getTransactionManager();
tm.commit();
try { conn.close(); } catch (SQLException se) {}
Transaction outerTxn = (Transaction)_outerTransaction.get();
if (outerTxn != null)
tm.resume(outerTxn);
} catch (Exception e) {
throw new StoreException(e);
} finally {
_outerTransaction.set(null);
}
} else {
try {
conn.commit();
} catch (SQLException se) {
throw SQLExceptions.getStore(se);
} finally {
try { conn.close(); } catch (SQLException se) {}
}
}
}
Close the current connection. |
public Object current(StoreContext ctx,
ClassMetaData meta) {
JDBCStore store = getStore(ctx);
try {
return currentInternal(store, (ClassMapping) meta);
} catch (OpenJPAException ke) {
throw ke;
} catch (SQLException se) {
throw SQLExceptions.getStore(se, store.getDBDictionary());
} catch (Exception e) {
throw new StoreException(e);
}
}
|
protected Object currentInternal(JDBCStore store,
ClassMapping mapping) throws Exception {
return current;
}
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. |
abstract public JDBCConfiguration getConfiguration()
|
protected Connection getConnection(JDBCStore store) throws SQLException {
if (type == TYPE_TRANSACTIONAL || type == TYPE_CONTIGUOUS)
return store.getConnection();
else if (suspendInJTA()) {
try {
TransactionManager tm = getConfiguration()
.getManagedRuntimeInstance().getTransactionManager();
_outerTransaction.set(tm.suspend());
tm.begin();
return store.getConnection();
} catch (Exception e) {
throw new StoreException(e);
}
} else {
JDBCConfiguration conf = store.getConfiguration();
DataSource ds = conf.getDataSource2(store.getContext());
Connection conn = ds.getConnection();
if (conn.getAutoCommit())
conn.setAutoCommit(false);
return conn;
}
}
Return the connection to use based on the type of sequence. This
connection will automatically be closed; do not close it. |
public Object next(StoreContext ctx,
ClassMetaData meta) {
JDBCStore store = getStore(ctx);
try {
current = nextInternal(store, (ClassMapping) meta);
return current;
} catch (OpenJPAException ke) {
throw ke;
} catch (SQLException se) {
throw SQLExceptions.getStore(se, store.getDBDictionary());
} catch (Exception e) {
throw new StoreException(e);
}
}
|
abstract protected Object nextInternal(JDBCStore store,
ClassMapping mapping) throws Exception
Return the next sequence object. |
public void setType(int type) {
this.type = type;
}
Records the sequence type. |
protected boolean suspendInJTA() {
return getConfiguration().isConnectionFactoryModeManaged() &&
getConfiguration().getConnectionFactory2() == null;
}
Detect whether or not OpenJPA should suspend the transaction in
a managed environment. |