public class SequenceImpl extends java.lang.Object implements DomainInterface, java.io.Serializable
String sqlStr = "SELECT CRM_INT_PROCESSES_SEQ.NEXTVAL FROM DUAL "; ViewObject View0 =appMod.createViewObjectFromQueryStmt("SeqView", sqlStr); Row idRow = View0.first();
When View0.first() (or last(), for that matter) is executed, the query is executed twice and sequence numbers are lost. Setting the View Object to setForwardOnly also has no effect.
This problem is caused by a JDBC bug that forces "prefetch" to be greater than or equal to 1. That is, when you execute the query for the View Object, it fetches at least one row before you call next(). This is why the sequence number increases by two.
Instead of instantiating a View Object, explicitly create a new sequence:
import oracle.jbo.server.SequenceImpl; . . SequenceImpl s = new SequenceImpl(sequenceName, thisTransaction); Number sVal = s.getSequenceNumber(); . . setYourSequenceAttribute(sVal); .
ViewObject
,
DBTransaction
,
ApplicationModule
,
Serialized FormConstructor and Description |
---|
SequenceImpl() |
SequenceImpl(java.lang.String seqName,
ApplicationModule am)
Constructor.
|
SequenceImpl(java.lang.String seqName,
DBTransaction trans)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.Object |
createInstanceWithAM(java.lang.String seqName,
ApplicationModule am)
A class method that may be invoked to retrieve the next value from a
database sequence.
|
boolean |
equals(java.lang.Object other)
Test if the specified value is equal to
this SequenceImpl
object. |
java.lang.Object |
getData()
Internal: Applications should not use this method.
Returns a sequence value.
|
Number |
getSequenceNumber()
Returns a sequence value.
|
int |
hashCode()
Computes a hash code for
this SequenceImpl object. |
void |
setContext(DomainOwnerInterface owner,
Transaction trans,
java.lang.Object ctx)
Internal: Applications should not use this method.
|
java.lang.String |
toString()
For testing purposes only: Returns a string representation of the
generated sequence value.
|
public SequenceImpl()
public SequenceImpl(java.lang.String seqName, ApplicationModule am)
seqName
- The name of the database sequence that will be used to
generate sequence values.am
- The application module instance that will provide the JDBC
connection for the sequence requests.public SequenceImpl(java.lang.String seqName, DBTransaction trans)
seqName
- The name of the database sequence that will be used to
generate sequence values.trans
- The Transaction instance that will provide the JDBC
connection for the sequence requests.public static java.lang.Object createInstanceWithAM(java.lang.String seqName, ApplicationModule am)
seqName
- The name of the database sequence that will be used to
generate the sequence value.am
- The application module instance that will provide the JDBC
connection for the sequence requestpublic java.lang.Object getData()
This method will increment the encapsulated database sequence the first time that it is invoked. Subsequent calls will return the same value.
getData
in interface DomainInterface
public Number getSequenceNumber()
This method will increment the encapsulated database sequence the first time that it is invoked. Subsequent calls will return the same value.
public void setContext(DomainOwnerInterface owner, Transaction trans, java.lang.Object ctx)
setContext
in interface DomainInterface
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object other)
this
SequenceImpl
object.equals
in class java.lang.Object
other
- The object to which the SequenceImpl should be compared.this
SequenceImpl.public int hashCode()
this
SequenceImpl object.hashCode
in class java.lang.Object
this
SequenceImpl object.