Interface SequenceSupport
- All Known Implementing Classes:
ANSISequenceSupport, DB2SequenceSupport, NextvalSequenceSupport
Defines database sequence value expressions and lifecycle DDL for a
Dialect.
Implement every database-specific difference as one stable, thread-safe strategy. The default methods provide ordinary single-statement create, drop, next-value, and restart grammar. Override the multi-statement methods only when one logical operation requires more than one SQL command.
An increment size of zero is invalid. Preserve the optional sequence-options
fragment exactly once, and use null nowhere as a capability signal;
databases without sequences must use SequenceSupports.none().
- Since:
- 8.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault StringgetCreateSequenceString(String sequenceName) Render the single command which creates a sequence with database-default allocation.default StringgetCreateSequenceString(String sequenceName, int initialValue, int incrementSize) Render the single command which creates a sequence with explicit allocation.default String[]getCreateSequenceStrings(String sequenceName, int initialValue, int incrementSize) Render every command required to create a pooled sequence without an options fragment.default String[]getCreateSequenceStrings(String sequenceName, int initialValue, int incrementSize, String options) Render every command required to create a pooled sequence, appending a non-empty options fragment exactly once to the final default command.default StringgetDropSequenceString(String sequenceName) Render the single command which drops a sequence.default String[]getDropSequenceStrings(String sequenceName) Render every command required to drop a sequence.default StringReturn the optional relation fragment appended to default stand-alone value-selection statements, including any required leading whitespace.default StringgetRestartSequenceString(String sequenceName, long startWith) Render the DDL command which restarts a sequence at a specified value.getSelectSequenceNextValString(String sequenceName) Render the expression which obtains the next value inside another SQL statement.default StringgetSelectSequencePreviousValString(String sequenceName) Render the expression which obtains the previous value inside another SQL statement.default StringgetSequenceNextValString(String sequenceName) Render a stand-alone statement which obtains the next sequence value.default StringgetSequenceNextValString(String sequenceName, int increment) Render a stand-alone next-value statement for databases whose selection syntax depends on the configured increment.default StringgetSequencePreviousValString(String sequenceName) Render a stand-alone statement which obtains the previous sequence value.default booleanReport whether creation must stateminvalueormaxvaluewhen the initial value and increment direction cross zero.default StringstartingValue(int initialValue, int incrementSize) Render the sign-sensitive starting bound required by this strategy.default booleanReport whether sequence creation accepts explicit initial and increment values.default booleanReport whether this strategy represents a database with sequences.
-
Method Details
-
supportsSequences
default boolean supportsSequences()Report whether this strategy represents a database with sequences.- Returns:
truewhen sequences are supported
-
supportsPooledSequences
default boolean supportsPooledSequences()Report whether sequence creation accepts explicit initial and increment values.- Returns:
truewhen pooled sequence definitions are supported- See Also:
-
getSelectSequenceNextValString
Render the expression which obtains the next value inside another SQL statement. Do not include a surroundingselectstatement.- Parameters:
sequenceName- the qualified sequence name- Returns:
- the next-value expression
- Throws:
MappingException- when the operation is unsupported
-
getSelectSequencePreviousValString
Render the expression which obtains the previous value inside another SQL statement. Override this method only when the database exposes such an expression.- Parameters:
sequenceName- the qualified sequence name- Returns:
- the previous-value expression
- Throws:
MappingException- when the operation is unsupported
-
getSequenceNextValString
Render a stand-alone statement which obtains the next sequence value.- Parameters:
sequenceName- the qualified sequence name- Returns:
- the next-value statement
- Throws:
MappingException- when the operation is unsupported
-
getSequencePreviousValString
Render a stand-alone statement which obtains the previous sequence value.- Parameters:
sequenceName- the qualified sequence name- Returns:
- the previous-value statement
- Throws:
MappingException- when the operation is unsupported
-
getFromDual
Return the optional relation fragment appended to default stand-alone value-selection statements, including any required leading whitespace. -
getSequenceNextValString
Render a stand-alone next-value statement for databases whose selection syntax depends on the configured increment.- Parameters:
sequenceName- the qualified sequence nameincrement- the configured increment- Returns:
- the next-value statement
- Throws:
MappingException- when the operation is unsupported
-
getCreateSequenceStrings
default String[] getCreateSequenceStrings(String sequenceName, int initialValue, int incrementSize, String options) throws MappingException Render every command required to create a pooled sequence, appending a non-empty options fragment exactly once to the final default command. Override this method when creation requires multiple commands.- Parameters:
sequenceName- the qualified sequence nameinitialValue- the initial sequence valueincrementSize- the nonzero sequence incrementoptions- the optional trailing SQL fragment- Returns:
- the ordered sequence-creation commands
- Throws:
MappingException- when the operation is unsupported or the increment is zero
-
getCreateSequenceStrings
default String[] getCreateSequenceStrings(String sequenceName, int initialValue, int incrementSize) throws MappingException Render every command required to create a pooled sequence without an options fragment.- Parameters:
sequenceName- the qualified sequence nameinitialValue- the initial sequence valueincrementSize- the nonzero sequence increment- Returns:
- the ordered sequence-creation commands
- Throws:
MappingException- when the operation is unsupported or the increment is zero
-
getCreateSequenceString
Render the single command which creates a sequence with database-default allocation. Override the multi-command form instead when one logical creation requires multiple commands.- Parameters:
sequenceName- the qualified sequence name- Returns:
- the sequence-creation command
- Throws:
MappingException- when the operation is unsupported
-
getCreateSequenceString
default String getCreateSequenceString(String sequenceName, int initialValue, int incrementSize) throws MappingException Render the single command which creates a sequence with explicit allocation. Reject an increment of zero and include any required sign-sensitive starting bound returned bystartingValue(int, int).- Parameters:
sequenceName- the qualified sequence nameinitialValue- the initial sequence valueincrementSize- the nonzero sequence increment- Returns:
- the sequence-creation command
- Throws:
MappingException- when the operation is unsupported or the increment is zero
-
getDropSequenceStrings
Render every command required to drop a sequence.- Parameters:
sequenceName- the qualified sequence name- Returns:
- the ordered sequence-drop commands
- Throws:
MappingException- when the operation is unsupported
-
getDropSequenceString
Render the single command which drops a sequence. Override the multi-command form instead when one logical drop requires several commands.- Parameters:
sequenceName- the qualified sequence name- Returns:
- the sequence-drop command
- Throws:
MappingException- when the operation is unsupported
-
getRestartSequenceString
-
sometimesNeedsStartingValue
default boolean sometimesNeedsStartingValue()Report whether creation must stateminvalueormaxvaluewhen the initial value and increment direction cross zero. -
startingValue
Render the sign-sensitive starting bound required by this strategy. Return an empty fragment when no explicit bound is needed.- Parameters:
initialValue- the initial sequence valueincrementSize- the sequence increment- Returns:
- a fragment including its own leading whitespace, or an empty string
-