Business Components

oracle.jbo.server
Class SequenceImpl

java.lang.Object
  |
  +--oracle.jbo.server.SequenceImpl

public class SequenceImpl
extends java.lang.Object
implements DomainInterface, java.io.Serializable

A represention of sequence Domain objects.

Creating View Objects and Generating Sequence Numbers

If you use createViewObjectFromQueryStmt to create View Objects, do not depend on it to correctly generate sequence numbers. This method causes sequence numbers to be generated twice. For example, if you create a View Object from a query statement which gets the next value from a sequence:

  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.

As a work around to this problem, explicitly create a new sequence:

 import oracle.jbo.server.SequenceImpl;
  .
  .
  SequenceImpl s = new SequenceImpl(sequenceName, thisTransaction);
    Integer  i = (Integer) s.getData();
  .
  .
    setYourSequenceAttribute(new Number(i));
  .
  

Since:
Jdeveloper 3.0
See Also:
ViewObject, DBTransaction, oracle.jbo.server.ApplicationModule, Serialized Form

Constructor Summary
SequenceImpl()
           
SequenceImpl(java.lang.String seqName, ApplicationModule am)
           
SequenceImpl(java.lang.String seqName, DBTransaction trans)
           
 
Method Summary
static java.lang.Object createInstanceWithAM(java.lang.String seqName, ApplicationModule am)
           
 boolean equals(java.lang.Object other)
           
 java.lang.Object getData()
          Returns the value in the format that is acceptable to the database.
 int hashCode()
           
 void setContext(DomainOwnerInterface owner, Transaction trans, java.lang.Object ctx)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SequenceImpl

public SequenceImpl()

SequenceImpl

public SequenceImpl(java.lang.String seqName,
                    ApplicationModule am)

SequenceImpl

public SequenceImpl(java.lang.String seqName,
                    DBTransaction trans)
Method Detail

createInstanceWithAM

public static java.lang.Object createInstanceWithAM(java.lang.String seqName,
                                                    ApplicationModule am)

getData

public java.lang.Object getData()
Description copied from interface: DomainInterface
Returns the value in the format that is acceptable to the database.

For domain classes based on oracle.sql.* classes, this method returns a Datum object. For domains based on java.lang types such as String, the value-holder object that is passed to JDBC is returned.

Specified by:
getData in interface DomainInterface
Tags copied from interface: DomainInterface
Returns:
a formatted value object.

setContext

public void setContext(DomainOwnerInterface owner,
                       Transaction trans,
                       java.lang.Object ctx)
Specified by:
setContext in interface DomainInterface

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

Business Components