Constructors Summary |
---|
public QuerySequence()
super();
|
public QuerySequence(String name)
super(name);
|
public QuerySequence(String name, int size)
super(name, size);
|
public QuerySequence(String name, int size, int initialValue)
super(name, size, initialValue);
|
public QuerySequence(boolean shouldAcquireValueAfterInsert, boolean shouldUseTransaction)
super();
setShouldAcquireValueAfterInsert(shouldAcquireValueAfterInsert);
setShouldUseTransaction(shouldUseTransaction);
|
public QuerySequence(String name, boolean shouldAcquireValueAfterInsert, boolean shouldUseTransaction)
super(name);
setShouldAcquireValueAfterInsert(shouldAcquireValueAfterInsert);
setShouldUseTransaction(shouldUseTransaction);
|
public QuerySequence(String name, int size, boolean shouldAcquireValueAfterInsert, boolean shouldUseTransaction)
super(name, size);
setShouldAcquireValueAfterInsert(shouldAcquireValueAfterInsert);
setShouldUseTransaction(shouldUseTransaction);
|
public QuerySequence(String name, int size, int initialValue, boolean shouldAcquireValueAfterInsert, boolean shouldUseTransaction)
super(name, size, initialValue);
setShouldAcquireValueAfterInsert(shouldAcquireValueAfterInsert);
setShouldUseTransaction(shouldUseTransaction);
|
Methods Summary |
---|
protected oracle.toplink.essentials.queryframework.ValueReadQuery | buildSelectQuery()INTERNAL:
return null;
|
protected oracle.toplink.essentials.queryframework.ValueReadQuery | buildSelectQuery(java.lang.String seqName, java.lang.Integer size)INTERNAL:
return null;
|
protected oracle.toplink.essentials.queryframework.DataModifyQuery | buildUpdateQuery()INTERNAL:
return null;
|
protected oracle.toplink.essentials.queryframework.DataModifyQuery | buildUpdateQuery(java.lang.String seqName, java.lang.Number sizeOrNewValue)INTERNAL:
return null;
|
protected java.util.Vector | createArguments(oracle.toplink.essentials.queryframework.DatabaseQuery query, java.lang.String seqName, java.lang.Number sizeOrNewValue)INTERNAL:
int nArgs = query.getArguments().size();
if (nArgs > 0) {
Vector args = new Vector(nArgs);
args.addElement(seqName);
if (nArgs > 1) {
args.addElement(sizeOrNewValue);
}
return args;
} else {
return null;
}
|
public boolean | equals(java.lang.Object obj)
if (obj instanceof QuerySequence && super.equals(obj)) {
QuerySequence other = (QuerySequence)obj;
return (getSelectQuery() == other.getSelectQuery()) && (getUpdateQuery() == other.getUpdateQuery()) && (shouldAcquireValueAfterInsert() == other.shouldAcquireValueAfterInsert()) && (shouldUseTransaction() == other.shouldUseTransaction()) && (shouldSkipUpdate() == other.shouldSkipUpdate()) && (shouldSelectBeforeUpdate() == other.shouldSelectBeforeUpdate());
} else {
return false;
}
|
public oracle.toplink.essentials.queryframework.ValueReadQuery | getSelectQuery()PUBLIC:
return selectQuery;
|
public oracle.toplink.essentials.queryframework.DataModifyQuery | getUpdateQuery()PUBLIC:
return updateQuery;
|
public void | onConnect()INTERNAL:
super.onConnect();
if (getSelectQuery() == null) {
setSelectQuery(buildSelectQuery());
wasSelectQueryCreated = getSelectQuery() != null;
}
if ((getUpdateQuery() == null) && !shouldSkipUpdate()) {
setUpdateQuery(buildUpdateQuery());
wasUpdateQueryCreated = getUpdateQuery() != null;
}
|
public void | onDisconnect()INTERNAL:
if (wasSelectQueryCreated) {
setSelectQuery(null);
wasSelectQueryCreated = false;
}
if (wasUpdateQueryCreated) {
setUpdateQuery(null);
wasUpdateQueryCreated = false;
}
super.onDisconnect();
|
protected java.lang.Object | select(oracle.toplink.essentials.internal.databaseaccess.Accessor accessor, oracle.toplink.essentials.internal.sessions.AbstractSession writeSession, java.lang.String seqName, java.lang.Integer size)INTERNAL:
ValueReadQuery query = getSelectQuery();
if (query != null) {
if (accessor != null) {
// PERF: Prepare the query before being cloned.
// Also BUG: SQLCall could not be prepared concurrently by different queries.
// Setting user define allow custom SQL query to be prepared without translation row.
query.setIsUserDefined(true);
query.checkPrepare(writeSession, null);
query = (ValueReadQuery)query.clone();
query.setAccessor(accessor);
}
} else {
query = buildSelectQuery(seqName, size);
if (accessor != null) {
query.setAccessor(accessor);
}
}
Vector args = createArguments(query, seqName, size);
if (args != null) {
return writeSession.executeQuery(query, args);
} else {
return writeSession.executeQuery(query);
}
|
public void | setSelectQuery(oracle.toplink.essentials.queryframework.ValueReadQuery query)PUBLIC:
selectQuery = query;
|
public void | setShouldAcquireValueAfterInsert(boolean shouldAcquireValueAfterInsert)PUBLIC:
this.shouldAcquireValueAfterInsert = shouldAcquireValueAfterInsert;
|
public void | setShouldSelectBeforeUpdate(boolean shouldSelectBeforeUpdate)PUBLIC:
this.shouldSelectBeforeUpdate = shouldSelectBeforeUpdate;
|
public void | setShouldSkipUpdate(boolean shouldSkipUpdate)PUBLIC:
this.shouldSkipUpdate = shouldSkipUpdate;
|
public void | setShouldUseTransaction(boolean shouldUseTransaction)PUBLIC:
this.shouldUseTransaction = shouldUseTransaction;
|
public void | setUpdateQuery(oracle.toplink.essentials.queryframework.DataModifyQuery query)PUBLIC:
updateQuery = query;
|
public boolean | shouldAcquireValueAfterInsert()PUBLIC:
return shouldAcquireValueAfterInsert;
|
public boolean | shouldSelectBeforeUpdate()PUBLIC:
return shouldSelectBeforeUpdate;
|
public boolean | shouldSkipUpdate()PUBLIC:
return shouldSkipUpdate;
|
public boolean | shouldUseTransaction()PUBLIC:
return shouldUseTransaction;
|
protected void | update(oracle.toplink.essentials.internal.databaseaccess.Accessor accessor, oracle.toplink.essentials.internal.sessions.AbstractSession writeSession, java.lang.String seqName, java.lang.Number sizeOrNewValue)INTERNAL:
DataModifyQuery query = getUpdateQuery();
if (query != null) {
if (accessor != null) {
// PERF: Prepare the query before being cloned.
// Also BUG: SQLCall could not be prepared concurrently by different queries.
// Setting user define allow custom SQL query to be prepared without translation row.
query.setIsUserDefined(true);
query.checkPrepare(writeSession, null);
query = (DataModifyQuery)query.clone();
query.setAccessor(accessor);
}
} else {
query = buildUpdateQuery(seqName, sizeOrNewValue);
if (query == null) {
return;
}
if (accessor != null) {
query.setAccessor(accessor);
}
}
Vector args = createArguments(query, seqName, sizeOrNewValue);
if (args != null) {
writeSession.executeQuery(query, args);
} else {
writeSession.executeQuery(query);
}
|
protected java.lang.Number | updateAndSelectSequence(oracle.toplink.essentials.internal.databaseaccess.Accessor accessor, oracle.toplink.essentials.internal.sessions.AbstractSession writeSession, java.lang.String seqName, int size)INTERNAL:
Integer sizeInteger = new Integer(size);
if (shouldSkipUpdate()) {
return (Number)select(accessor, writeSession, seqName, sizeInteger);
} else {
if (shouldSelectBeforeUpdate()) {
Object result = select(accessor, writeSession, seqName, sizeInteger);
BigDecimal currentValue;
if (result instanceof Number) {
currentValue = new BigDecimal(((Number)result).longValue());
} else if (result instanceof String) {
currentValue = new BigDecimal((String)result);
} else if (result instanceof Record) {
Object val = ((Record)result).get("text()");
currentValue = new BigDecimal((String)val);
} else {
// DatabaseException.errorPreallocatingSequenceNumbers() is thrown by the superclass
return null;
}
// Increment value
BigDecimal newValue = currentValue.add(new BigDecimal(size));
update(accessor, writeSession, seqName, newValue);
return newValue;
} else {
update(accessor, writeSession, seqName, sizeInteger);
return (Number)select(accessor, writeSession, seqName, sizeInteger);
}
}
|