public abstract class Sequence extends Object implements Serializable, Cloneable
Purpose: Define an interface for sequencing customization.
Description: Customary sequencing behavior could be achieved by implementing this interface and passing the instance to DatabaseSession.getSequencingControl().setValueGenerationPolicy(..). TopLink internally uses the same method to set its default implementation of this interface, which provides native sequencing and table sequencing. Note that the following methods: shouldAcquireValueAfterInsert(); shouldUsePreallocation(); shouldUseSeparateConnection(); shouldUseTransaction(); are called only once - during creation of the sequencing object. Therefore during the lifetime of sequencing object these methods should return the same values as when called for the first time. If this is not true - resetSequencing (call SequencingControl.resetSequencing()).
Responsibilities:
SequencingControl
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected int |
depth |
protected int |
initialValue |
protected String |
name |
protected Platform |
platform |
protected int |
size |
Constructor and Description |
---|
Sequence() |
Sequence(String name) |
Sequence(String name,
int size) |
Sequence(String name,
int size,
int initialValue) |
Modifier and Type | Method and Description |
---|---|
Object |
clone() |
static boolean |
equalNameAndSize(Sequence seq1,
Sequence seq2) |
boolean |
equals(Object obj) |
Platform |
getDatasourcePlatform() |
Object |
getGeneratedValue(Accessor accessor,
AbstractSession writeSession)
INTERNAL:
Return the newly-generated sequencing value.
|
abstract Object |
getGeneratedValue(Accessor accessor,
AbstractSession writeSession,
String seqName)
INTERNAL:
Return the newly-generated sequencing value.
|
Vector |
getGeneratedVector(Accessor accessor,
AbstractSession writeSession)
INTERNAL:
Return a Vector of newly-generated sequencing values.
|
abstract Vector |
getGeneratedVector(Accessor accessor,
AbstractSession writeSession,
String seqName,
int size)
INTERNAL:
Return a Vector of newly-generated sequencing values.
|
int |
getInitialValue() |
String |
getName() |
int |
getPreallocationSize() |
boolean |
isConnected()
PUBLIC:
Indicates that Sequence is connected.
|
protected abstract void |
onConnect()
INTERNAL:
This method is called when Sequencing object is created.
|
void |
onConnect(Platform platform)
INTERNAL:
This method is called when Sequencing object is created.
|
protected abstract void |
onDisconnect()
INTERNAL:
This method is called when Sequencing object is destroyed.
|
void |
onDisconnect(Platform platform)
INTERNAL:
This method is called when Sequencing object is destroyed.
|
protected void |
setDatasourcePlatform(Platform platform) |
void |
setInitialValue(int initialValue) |
void |
setName(String name) |
void |
setPreallocationSize(int size) |
abstract boolean |
shouldAcquireValueAfterInsert()
INTERNAL:
Indicates whether sequencing value should be acquired after INSERT.
|
boolean |
shouldOverrideExistingValue(Object existingValue)
INTERNAL:
Indicates whether existing attribute value should be overridden.
|
abstract boolean |
shouldOverrideExistingValue(String seqName,
Object existingValue)
INTERNAL:
Indicates whether existing attribute value should be overridden.
|
boolean |
shouldUsePreallocation()
INTERNAL:
Indicates whether several sequencing values should be acquired at a time
and be kept by TopLink.
|
abstract boolean |
shouldUseTransaction()
INTERNAL:
Indicates whether TopLink should internally call beginTransaction() before
getGeneratedValue/Vector, and commitTransaction after.
|
protected void |
verifyPlatform(Platform otherPlatform)
INTERNAL:
Make sure that the sequence is not used by more than one platform.
|
protected String name
protected int size
protected Platform platform
protected int initialValue
protected int depth
public Sequence()
public Sequence(String name)
public Sequence(String name, int size)
public Sequence(String name, int size, int initialValue)
public String getName()
public void setName(String name)
public int getPreallocationSize()
public void setPreallocationSize(int size)
public int getInitialValue()
public void setInitialValue(int initialValue)
protected void setDatasourcePlatform(Platform platform)
public Platform getDatasourcePlatform()
public abstract boolean shouldAcquireValueAfterInsert()
public boolean shouldUsePreallocation()
public abstract boolean shouldUseTransaction()
public abstract boolean shouldOverrideExistingValue(String seqName, Object existingValue)
seqName
- String is sequencing number field nameexistingValue
- Object is a non-null value of PK-mapped attribute.public boolean shouldOverrideExistingValue(Object existingValue)
existingValue
- Object is a non-null value of PK-mapped attribute.public abstract Object getGeneratedValue(Accessor accessor, AbstractSession writeSession, String seqName)
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 namepublic Object getGeneratedValue(Accessor accessor, AbstractSession writeSession)
accessor
- Accessor is a separate sequencing accessor (may be null);writeSession
- Session is a Session used for writing (either ClientSession or DatabaseSession);public abstract Vector getGeneratedVector(Accessor accessor, AbstractSession writeSession, String seqName, int size)
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).public Vector getGeneratedVector(Accessor accessor, AbstractSession writeSession)
accessor
- Accessor is a separate sequencing accessor (may be null);writeSession
- Session is a Session used for writing (either ClientSession or DatabaseSession);public void onConnect(Platform platform)
ownerSession
- DatabaseSessionprotected abstract void onConnect()
ownerSession
- DatabaseSessionpublic void onDisconnect(Platform platform)
protected abstract void onDisconnect()
public boolean isConnected()
protected void verifyPlatform(Platform otherPlatform)
Copyright © 2024. All rights reserved.