Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client
11g Release 1 (11.1.1)

E17503-02

oracle.jbo.server
Class SequenceImpl

java.lang.Object
  extended by oracle.jbo.server.SequenceImpl
All Implemented Interfaces:
Serializable, DomainInterface

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

An encapsulation of a database sequence. This class provides a Java wrapper for a database sequence and may be used whenever it is necessary to query sequence values from a database sequence. See the discussion below for more information on using this class to query database sequences instead of instantiating a dynamic View Object.

Creating View Objects and Generating Sequence Numbers

If you use createViewObjectFromQueryStmt to create View Objects that query database sequences, do not depend on the view object to correctly generate sequence numbers. The process of querying the View Object for sequence numbers 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.

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);
  .
 

Since:
Jdeveloper 3.0
See Also:
ViewObject, DBTransaction, ApplicationModule

Field Summary
static java.lang.Class CLASS_INSTANCE
           
 
Constructor Summary
SequenceImpl(java.lang.Long value)
           
SequenceImpl(java.lang.String seqName, ApplicationModule am)
          Constructor.
SequenceImpl(java.lang.String seqName, Connection conn, ConnectionDetails details)
           
SequenceImpl(java.lang.String seqName, DBTransaction trans)
          Constructor.
 
Method Summary
static java.lang.String determineSequenceName(java.lang.String applicationName, java.lang.String tableName)
          Internal use only.
 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.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS_INSTANCE

public static final java.lang.Class CLASS_INSTANCE
Constructor Detail

SequenceImpl

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

Parameters:
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.

SequenceImpl

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

Parameters:
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.

SequenceImpl

public SequenceImpl(java.lang.String seqName,
                    Connection conn,
                    ConnectionDetails details)

SequenceImpl

public SequenceImpl(java.lang.Long value)
Method Detail

setContext

public void setContext(DomainOwnerInterface owner,
                       Transaction trans,
                       java.lang.Object ctx)
Internal: Applications should not use this method.

Specified by:
setContext in interface DomainInterface

getData

public java.lang.Object getData()
Internal: Applications should not use this method. Returns a sequence value. The sequence value is generated by the database sequence that was specified when constructing the SequenceImpl object.

This method will increment the encapsulated database sequence the first time that it is invoked. Subsequent calls will return the same value.

Specified by:
getData in interface DomainInterface
Returns:
An object representing the next sequence value.

getSequenceNumber

public Number getSequenceNumber()
Returns a sequence value. The sequence value is generated by the database sequence that was specified when constructing the SequenceImpl object.

This method will increment the encapsulated database sequence the first time that it is invoked. Subsequent calls will return the same value.

Returns:
An instance of oracle.jbo.domain.Number representing the next sequence value.

toString

public java.lang.String toString()
For testing purposes only: Returns a string representation of the generated sequence value.

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object other)
Test if the specified value is equal to this SequenceImpl object.

Overrides:
equals in class java.lang.Object
Parameters:
other - The object to which the SequenceImpl should be compared.
Returns:
true The specified object is equal to the this SequenceImpl.

hashCode

public int hashCode()
Computes a hash code for this SequenceImpl object.

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code of this SequenceImpl object.

determineSequenceName

public static java.lang.String determineSequenceName(java.lang.String applicationName,
                                                     java.lang.String tableName)
Internal use only. This determines the PK sequence name, as generated by Tadashi's algorithm.

Parameters:
schemaName -
applicationName -
tableName -
Returns:

Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client
11g Release 1 (11.1.1)

E17503-02

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.