Top Description Fields Constructors Methods
org.eclipse.persistence.sequencing

public abstract Class Sequence

extends Object
implements Serializable, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, java.io.Serializable
Known Direct Subclasses
org.eclipse.persistence.sequencing.StandardSequence, org.eclipse.persistence.sequencing.UUIDSequence, org.eclipse.persistence.sequencing.DefaultSequence
Imports
java.util.Vector, java.io.Serializable, org.eclipse.persistence.internal.databaseaccess.Platform, .Accessor, org.eclipse.persistence.internal.sessions.AbstractSession, org.eclipse.persistence.exceptions.ValidationException

Purpose: Abstract class to define sequencing.

Description A sequence defines how generated ids are obtained. The main sequence types are TableSequence and NativeSequence. Descriptors using sequencing will use the sequence object defined in their session's DatabaseLogin with the name matching their sequence name. If a specific sequence is not defined for the name the DatabaseLogin's default sequence will be used.

See Also
TableSequence, NativeSequence

Field Summary

Modifier and TypeField and Description
protected int
protected int
protected boolean
protected String
protected Platform
protected String
protected boolean
protected int

Constructor Summary

AccessConstructor and Description
protected
protected
Sequence(String name)

Create a new sequence with the name.

protected
Sequence(String name, int size)

Create a new sequence with the name and sequence pre-allocation size.

protected
Sequence(String name, int size, int initialValue)

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
public static boolean
equalNameAndSize(Sequence seq1, Sequence seq2)

INTERNAL: Used in equals.

public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public Platform
public abstract Object
getGeneratedValue(Accessor
Accessor is a separate sequencing accessor (may be null);
accessor
,
AbstractSession
Session is a Session used for writing (either ClientSession or DatabaseSession);
writeSession
,
String
String is sequencing number field name
seqName
)

INTERNAL: Return the newly-generated sequencing value.

public Object
getGeneratedValue(Accessor
Accessor is a separate sequencing accessor (may be null);
accessor
,
AbstractSession
Session is a Session used for writing (either ClientSession or DatabaseSession);
writeSession
)

INTERNAL: Return the newly-generated sequencing value.

public abstract Vector<?>
getGeneratedVector(Accessor
Accessor is a separate sequencing accessor (may be null);
accessor
,
AbstractSession
Session is a Session used for writing (either ClientSession or DatabaseSession);
writeSession
,
String
String is sequencing number field name
seqName
,
int
int number of values to preallocate (output Vector size).
size
)

INTERNAL: Return a Vector of newly-generated sequencing values.

public Vector<?>
getGeneratedVector(Accessor
Accessor is a separate sequencing accessor (may be null);
accessor
,
AbstractSession
Session is a Session used for writing (either ClientSession or DatabaseSession);
writeSession
)

INTERNAL: Return a Vector of newly-generated sequencing values.

public int
public String
public int
public String
getQualified(String str)

INTERNAL:

public String
getQualifier()

INTERNAL:

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public boolean
isConnected()

PUBLIC: Indicates that Sequence is connected.

public boolean
isCustomQualifier()

INTERNAL:

public boolean
public boolean
public boolean
public void
onConnect(Platform platform)

INTERNAL: This method is called when Sequencing object is created.

public abstract void
onConnect()

INTERNAL: This method is called when Sequencing object is created.

public void
onDisconnect(Platform platform)

INTERNAL: This method is called when Sequencing object is destroyed.

public abstract void
onDisconnect()

INTERNAL: This method is called when Sequencing object is destroyed.

protected void
public void
setInitialValue(int initialValue)

public void
public void
public void
setQualifier(String qualifier)

INTERNAL:

public void
setShouldAlwaysOverrideExistingValue(boolean shouldAlwaysOverrideExistingValue)

ADVANCED: Set that to true if the sequence should always override the existing pk value.

public abstract boolean
shouldAcquireValueAfterInsert()

INTERNAL: Indicates whether sequencing value should be acquired after INSERT.

public boolean
shouldAlwaysOverrideExistingValue()

INTERNAL: Indicates whether the existing pk value should always be overridden by the sequence.

public boolean
shouldAlwaysOverrideExistingValue(String seqName)

INTERNAL: Indicates whether the existing pk value should always be overridden by the sequence.

public boolean
shouldUsePreallocation()

INTERNAL: Indicates whether several sequencing values should be acquired at a time and be kept by TopLink.

public abstract boolean
shouldUseTransaction()

INTERNAL: Indicates whether TopLink should internally call beginTransaction() before getGeneratedValue/Vector, and commitTransaction after.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
protected void
verifyPlatform(Platform otherPlatform)

INTERNAL: Make sure that the sequence is not used by more than one platform.

Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

depthback to summary
protected int depth
initialValueback to summary
protected int initialValue
isCustomQualifierback to summary
protected boolean isCustomQualifier
nameback to summary
protected String name
platformback to summary
protected Platform platform
qualifierback to summary
protected String qualifier
shouldAlwaysOverrideExistingValueback to summary
protected boolean shouldAlwaysOverrideExistingValue
sizeback to summary
protected int size

Constructor Detail

Sequenceback to summary
protected Sequence()
Sequenceback to summary
protected Sequence(String name)

Create a new sequence with the name.

Sequenceback to summary
protected Sequence(String name, int size)

Create a new sequence with the name and sequence pre-allocation size.

Sequenceback to summary
protected Sequence(String name, int size, int initialValue)

Method Detail

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:Object

a clone of this instance.

Annotations
@Override
equalNameAndSizeback to summary
public static boolean equalNameAndSize(Sequence seq1, Sequence seq2)

INTERNAL: Used in equals.

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getDatasourcePlatformback to summary
public Platform getDatasourcePlatform()
getGeneratedValueback to summary
public abstract Object getGeneratedValue(Accessor accessor, AbstractSession writeSession, String seqName)

INTERNAL: Return the newly-generated sequencing value. Used only in case preallocation is not used (shouldUsePreallocation()==false). Accessor may be non-null only in case shouldUseSeparateConnection()==true. Even in this case accessor could be null - if SequencingControl().shouldUseSeparateConnection()==false; Therefore in case shouldUseSeparateConnection()==true, implementation should handle both cases: use a separate connection if provided (accessor != null), or get by without it (accessor == null).

Parameters
accessor:Accessor

Accessor is a separate sequencing accessor (may be null);

writeSession:AbstractSession

Session is a Session used for writing (either ClientSession or DatabaseSession);

seqName:String

String is sequencing number field name

getGeneratedValueback to summary
public Object getGeneratedValue(Accessor accessor, AbstractSession writeSession)

INTERNAL: Return the newly-generated sequencing value. Used only in case preallocation is not used (shouldUsePreallocation()==false). Accessor may be non-null only in case shouldUseSeparateConnection()==true. Even in this case accessor could be null - if SequencingControl().shouldUseSeparateConnection()==false; Therefore in case shouldUseSeparateConnection()==true, implementation should handle both cases: use a separate connection if provided (accessor != null), or get by without it (accessor == null).

Parameters
accessor:Accessor

Accessor is a separate sequencing accessor (may be null);

writeSession:AbstractSession

Session is a Session used for writing (either ClientSession or DatabaseSession);

getGeneratedVectorback to summary
public abstract Vector<?> getGeneratedVector(Accessor accessor, AbstractSession writeSession, String seqName, int size)

INTERNAL: Return a Vector of newly-generated sequencing values. Used only in case preallocation is used (shouldUsePreallocation()==true). Accessor may be non-null only in case shouldUseSeparateConnection()==true. Even in this case accessor could be null - if SequencingControl().shouldUseSeparateConnection()==false; Therefore in case shouldUseSeparateConnection()==true, implementation should handle both cases: use a separate connection if provided (accessor != null), or get by without it (accessor == null).

Parameters
accessor:Accessor

Accessor is a separate sequencing accessor (may be null);

writeSession:AbstractSession

Session is a Session used for writing (either ClientSession or DatabaseSession);

seqName:String

String is sequencing number field name

size:int

int number of values to preallocate (output Vector size).

getGeneratedVectorback to summary
public Vector<?> getGeneratedVector(Accessor accessor, AbstractSession writeSession)

INTERNAL: Return a Vector of newly-generated sequencing values. Used only in case preallocation is used (shouldUsePreallocation()==true). Accessor may be non-null only in case shouldUseSeparateConnection()==true. Even in this case accessor could be null - if SequencingControl().shouldUseSeparateConnection()==false; Therefore in case shouldUseSeparateConnection()==true, implementation should handle both cases: use a separate connection if provided (accessor != null), or get by without it (accessor == null).

Parameters
accessor:Accessor

Accessor is a separate sequencing accessor (may be null);

writeSession:AbstractSession

Session is a Session used for writing (either ClientSession or DatabaseSession);

getInitialValueback to summary
public int getInitialValue()
getNameback to summary
public String getName()
getPreallocationSizeback to summary
public int getPreallocationSize()
getQualifiedback to summary
public String getQualified(String str)

INTERNAL:

getQualifierback to summary
public String getQualifier()

INTERNAL:

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
isConnectedback to summary
public boolean isConnected()

PUBLIC: Indicates that Sequence is connected.

isCustomQualifierback to summary
public boolean isCustomQualifier()

INTERNAL:

isNativeback to summary
public boolean isNative()
isTableback to summary
public boolean isTable()
isUnaryTableback to summary
public boolean isUnaryTable()
onConnectback to summary
public void onConnect(Platform platform)

INTERNAL: This method is called when Sequencing object is created. Don't override this method.

onConnectback to summary
public abstract void onConnect()

INTERNAL: This method is called when Sequencing object is created. If it requires initialization, subclass should override this method.

onDisconnectback to summary
public void onDisconnect(Platform platform)

INTERNAL: This method is called when Sequencing object is destroyed. Don't override this method.

onDisconnectback to summary
public abstract void onDisconnect()

INTERNAL: This method is called when Sequencing object is destroyed. If it requires deinitialization, subclass should override this method.

setDatasourcePlatformback to summary
protected void setDatasourcePlatform(Platform platform)
setInitialValueback to summary
public void setInitialValue(int initialValue)
setNameback to summary
public void setName(String name)
setPreallocationSizeback to summary
public void setPreallocationSize(int size)
setQualifierback to summary
public void setQualifier(String qualifier)

INTERNAL:

setShouldAlwaysOverrideExistingValueback to summary
public void setShouldAlwaysOverrideExistingValue(boolean shouldAlwaysOverrideExistingValue)

ADVANCED: Set that to true if the sequence should always override the existing pk value.

shouldAcquireValueAfterInsertback to summary
public abstract boolean shouldAcquireValueAfterInsert()

INTERNAL: Indicates whether sequencing value should be acquired after INSERT. Note that preallocation could be used only in case sequencing values should be acquired before insert (this method returns false). In default implementation, it is true for table sequencing and native sequencing on Oracle platform, false for native sequencing on other platforms.

shouldAlwaysOverrideExistingValueback to summary
public boolean shouldAlwaysOverrideExistingValue()

INTERNAL: Indicates whether the existing pk value should always be overridden by the sequence. As always the version of the method taking seqName is provided for the benefit of DefaultSequence.

shouldAlwaysOverrideExistingValueback to summary
public boolean shouldAlwaysOverrideExistingValue(String seqName)

INTERNAL: Indicates whether the existing pk value should always be overridden by the sequence.

shouldUsePreallocationback to summary
public boolean shouldUsePreallocation()

INTERNAL: Indicates whether several sequencing values should be acquired at a time and be kept by TopLink. This in only possible in case sequencing numbers should be acquired before insert (shouldAcquireValueAfterInsert()==false). In default implementation, it is true for table sequencing and native sequencing on Oracle platform, false for native sequencing on other platforms.

shouldUseTransactionback to summary
public abstract boolean shouldUseTransaction()

INTERNAL: Indicates whether TopLink should internally call beginTransaction() before getGeneratedValue/Vector, and commitTransaction after. In default implementation, it is true for table sequencing and false for native sequencing.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
verifyPlatformback to summary
protected void verifyPlatform(Platform otherPlatform)

INTERNAL: Make sure that the sequence is not used by more than one platform.