Class DefaultSequence
java.lang.Object
org.eclipse.persistence.sequencing.Sequence
org.eclipse.persistence.sequencing.DefaultSequence
- All Implemented Interfaces:
Serializable
,Cloneable
Purpose: Reference to the default sequence.
Description This sequence can be used to provide a sequence using the session's default sequencing mechanism but override the pre-allocation size.
- See Also:
-
Field Summary
Fields inherited from class org.eclipse.persistence.sequencing.Sequence
depth, initialValue, isCustomQualifier, name, platform, qualifier, shouldAlwaysOverrideExistingValue, size
-
Constructor Summary
ConstructorDescriptionDefaultSequence
(String name) Create a new sequence with the name.DefaultSequence
(String name, int size) Create a new sequence with the name and sequence pre-allocation size.DefaultSequence
(String name, int size, int initialValue) -
Method Summary
Modifier and TypeMethodDescriptionboolean
INTERNAL: Return the platform's default sequence.getGeneratedValue
(org.eclipse.persistence.internal.databaseaccess.Accessor accessor, org.eclipse.persistence.internal.sessions.AbstractSession writeSession, String seqName) INTERNAL: Return the newly-generated sequencing value.getGeneratedVector
(org.eclipse.persistence.internal.databaseaccess.Accessor accessor, org.eclipse.persistence.internal.sessions.AbstractSession writeSession, String seqName, int size) INTERNAL: Return a Vector of newly-generated sequencing values.int
int
int
hashCode()
boolean
boolean
PUBLIC: Indicates that Sequence is connected.void
INTERNAL: This method is called when Sequencing object is created.void
INTERNAL: This method is called when Sequencing object is destroyed..void
setQualifier
(String qualifier) INTERNAL: Ignored, getDefaultSequence().getQualifier() used instead.boolean
INTERNAL: Indicates whether sequencing value should be acquired after INSERT.boolean
shouldAlwaysOverrideExistingValue
(String seqName) INTERNAL: Indicates whether the existing pk value should always be overridden by the sequence.boolean
INTERNAL: Indicates whether several sequencing values should be acquired at a time and be kept by TopLink.boolean
INTERNAL: Indicates whether EclipseLink should internally call beginTransaction() before getGeneratedValue/Vector, and commitTransaction after.Methods inherited from class org.eclipse.persistence.sequencing.Sequence
clone, equalNameAndSize, getDatasourcePlatform, getGeneratedValue, getGeneratedVector, getName, getQualified, getQualifier, isCustomQualifier, isNative, isTable, isUnaryTable, onConnect, onDisconnect, setDatasourcePlatform, setInitialValue, setName, setPreallocationSize, setShouldAlwaysOverrideExistingValue, shouldAlwaysOverrideExistingValue, toString, verifyPlatform
-
Constructor Details
-
DefaultSequence
public DefaultSequence() -
DefaultSequence
Create a new sequence with the name. -
DefaultSequence
Create a new sequence with the name and sequence pre-allocation size. -
DefaultSequence
-
-
Method Details
-
getDefaultSequence
INTERNAL: Return the platform's default sequence. -
hasPreallocationSize
public boolean hasPreallocationSize() -
getPreallocationSize
public int getPreallocationSize()- Overrides:
getPreallocationSize
in classSequence
-
getInitialValue
public int getInitialValue()- Overrides:
getInitialValue
in classSequence
-
equals
-
hashCode
public int hashCode() -
shouldAcquireValueAfterInsert
public 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.- Specified by:
shouldAcquireValueAfterInsert
in classSequence
-
shouldAlwaysOverrideExistingValue
INTERNAL: Indicates whether the existing pk value should always be overridden by the sequence.- Overrides:
shouldAlwaysOverrideExistingValue
in classSequence
-
shouldUsePreallocation
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.- Overrides:
shouldUsePreallocation
in classSequence
-
shouldUseTransaction
public boolean shouldUseTransaction()INTERNAL: Indicates whether EclipseLink should internally call beginTransaction() before getGeneratedValue/Vector, and commitTransaction after. In default implementation, it is true for table sequencing and false for native sequencing.- Specified by:
shouldUseTransaction
in classSequence
-
getGeneratedValue
public Object getGeneratedValue(org.eclipse.persistence.internal.databaseaccess.Accessor accessor, org.eclipse.persistence.internal.sessions.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).- Specified by:
getGeneratedValue
in classSequence
- Parameters:
accessor
- Accessor is a separate sequencing accessor (may be null);writeSession
- Session is a Session used for writing (either ClientSession or DatabaseSession);seqName
- String is sequencing number field name
-
getGeneratedVector
public Vector getGeneratedVector(org.eclipse.persistence.internal.databaseaccess.Accessor accessor, org.eclipse.persistence.internal.sessions.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).- Specified by:
getGeneratedVector
in classSequence
- Parameters:
accessor
- Accessor is a separate sequencing accessor (may be null);writeSession
- Session is a Session used for writing (either ClientSession or DatabaseSession);seqName
- String is sequencing number field namesize
- int number of values to preallocate (output Vector size).
-
onConnect
public void onConnect()INTERNAL: This method is called when Sequencing object is created. It's a chance to do initialization. -
onDisconnect
public void onDisconnect()INTERNAL: This method is called when Sequencing object is destroyed.. It's a chance to do deinitialization.- Specified by:
onDisconnect
in classSequence
-
isConnected
public boolean isConnected()PUBLIC: Indicates that Sequence is connected.- Overrides:
isConnected
in classSequence
-
setQualifier
INTERNAL: Ignored, getDefaultSequence().getQualifier() used instead.- Overrides:
setQualifier
in classSequence
-