Top Description Methods
org.hibernate.dialect.sequence

public Interface SequenceSupport

Known Direct Implementers
org.hibernate.dialect.sequence.TiDBSequenceSupport, org.hibernate.dialect.sequence.ANSISequenceSupport, org.hibernate.dialect.sequence.DB2iSequenceSupport, org.hibernate.dialect.sequence.DB2zSequenceSupport, org.hibernate.dialect.sequence.H2V1SequenceSupport, org.hibernate.dialect.sequence.LegacyDB2SequenceSupport, org.hibernate.dialect.sequence.NextvalSequenceSupport, org.hibernate.dialect.sequence.NoSequenceSupport, org.hibernate.dialect.sequence.PostgreSQLSequenceSupport
Imports
org.hibernate.MappingException

A set of operations providing support for sequences in a certain SQL dialect.
Author
Gavin King

Method Summary

Modifier and TypeMethod and Description
public default String

Returns:

The sequence creation command
getCreateSequenceString
(String
The name of the sequence
sequenceName
)

Typically dialects which support sequences can create a sequence with a single command.

public default String

Returns:

The sequence creation command
getCreateSequenceString
(String
The name of the sequence
sequenceName
,
int
The initial value to apply to 'create sequence' statement
initialValue
,
int
The increment value to apply to 'create sequence' statement
incrementSize
)

Typically dialects which support sequences can create a sequence with a single command.

public default String[]

Returns:

The sequence creation commands
getCreateSequenceStrings
(String
The name of the sequence
sequenceName
,
int
The initial value to apply to 'create sequence' statement
initialValue
,
int
The increment value to apply to 'create sequence' statement
incrementSize
)

An optional multi-line form for databases which supportsPooledSequences().

public default String

Returns:

The sequence drop commands
getDropSequenceString
(String
The name of the sequence
sequenceName
)

Typically dialects which support sequences can drop a sequence with a single command.

public default String[]

Returns:

The sequence drop commands
getDropSequenceStrings
(String
The name of the sequence
sequenceName
)

The multiline script used to drop a sequence.

public default String
public String

Returns:

The "next value" fragment.
getSelectSequenceNextValString
(String
the name of the sequence
sequenceName
)

Generate the select expression fragment that will retrieve the next value of a sequence as part of another (typically DML) statement.

public default String

Returns:

The "previous value" fragment.
getSelectSequencePreviousValString
(String
the name of the sequence
sequenceName
)

Generate the select expression fragment that will retrieve the previous value of a sequence as part of another (typically DML) statement.

public default String

Returns:

String The select "next value" statement.
getSequenceNextValString
(String
the name of the sequence
sequenceName
)

Generate the appropriate select statement to to retrieve the next value of a sequence.

public default String

Returns:

String The select "next value" statement.
getSequenceNextValString
(String
the name of the sequence
sequenceName
,
int
the increment, in case it needs to be passed explicitly
increment
)

Generate the appropriate select statement to to retrieve the next value of a sequence.

public default String

Returns:

String The select "previous value" statement.
getSequencePreviousValString
(String
the name of the sequence
sequenceName
)

Generate the appropriate select statement to to retrieve the previous value of a sequence.

public default boolean
sometimesNeedsStartingValue()

Do we need to explicitly specify minvalue or maxvalue when the initial value doesn't have the same sign as the increment?

public default String
startingValue(int initialValue, int incrementSize)

public default boolean

Returns:

True if such "pooled" sequences are supported; false otherwise.
supportsPooledSequences
()

Does this dialect support "pooled" sequences.

public default boolean

Returns:

True if sequences supported; false otherwise.
supportsSequences
()

Does this dialect support sequences?

Method Detail

getCreateSequenceStringback to summary
public default String getCreateSequenceString(String sequenceName) throws MappingException

Typically dialects which support sequences can create a sequence with a single command. This method is a convenience making it easier to implement getCreateSequenceStrings(String, int, int) for these dialects.

The default definition is to return create sequence sequenceName for the argument sequenceName. Dialects need to override this method if a sequence created in this manner does not start at 1, or if the syntax is nonstandard.

Dialects which support sequences and can create a sequence in a single command need *only* override this method. Dialects which support sequences but require multiple commands to create a sequence should override getCreateSequenceStrings(String, int, int) instead.

Parameters
sequenceName:String

The name of the sequence

Returns:String

The sequence creation command

Exceptions
MappingException:
If sequences are not supported.
getCreateSequenceStringback to summary
public default String getCreateSequenceString(String sequenceName, int initialValue, int incrementSize) throws MappingException

Typically dialects which support sequences can create a sequence with a single command. This method is a convenience making it easier to implement getCreateSequenceStrings(String, int, int) for these dialects.

Overloaded form of getCreateSequenceString(String), additionally taking the initial value and increment size to be applied to the sequence definition.

The default definition is to suffix getCreateSequenceString(String) with the string: start with initialValue increment by incrementSize for the arguments initialValue and incrementSize. Dialects need to override this method if different key phrases are used to apply the allocation information.
Parameters
sequenceName:String

The name of the sequence

initialValue:int

The initial value to apply to 'create sequence' statement

incrementSize:int

The increment value to apply to 'create sequence' statement

Returns:String

The sequence creation command

Exceptions
MappingException:
If sequences are not supported.
getCreateSequenceStringsback to summary
public default String[] getCreateSequenceStrings(String sequenceName, int initialValue, int incrementSize) throws MappingException

An optional multi-line form for databases which supportsPooledSequences().

Parameters
sequenceName:String

The name of the sequence

initialValue:int

The initial value to apply to 'create sequence' statement

incrementSize:int

The increment value to apply to 'create sequence' statement

Returns:String[]

The sequence creation commands

Exceptions
MappingException:
If sequences are not supported.
getDropSequenceStringback to summary
public default String getDropSequenceString(String sequenceName) throws MappingException

Typically dialects which support sequences can drop a sequence with a single command. This is convenience form of getDropSequenceStrings to help facilitate that.

Dialects which support sequences and can drop a sequence in a single command need *only* override this method. Dialects which support sequences but require multiple commands to drop a sequence should instead override getDropSequenceStrings.

Parameters
sequenceName:String

The name of the sequence

Returns:String

The sequence drop commands

Exceptions
MappingException:
If sequences are not supported.
getDropSequenceStringsback to summary
public default String[] getDropSequenceStrings(String sequenceName) throws MappingException

The multiline script used to drop a sequence.

Parameters
sequenceName:String

The name of the sequence

Returns:String[]

The sequence drop commands

Exceptions
MappingException:
If sequences are not supported.
getFromDualback to summary
public default String getFromDual()
getSelectSequenceNextValStringback to summary
public String getSelectSequenceNextValString(String sequenceName) throws MappingException

Generate the select expression fragment that will retrieve the next value of a sequence as part of another (typically DML) statement.

This differs from getSequenceNextValString(String) in that it must return an expression usable within another statement.

Parameters
sequenceName:String

the name of the sequence

Returns:String

The "next value" fragment.

Exceptions
MappingException:
If sequences are not supported.
getSelectSequencePreviousValStringback to summary
public default String getSelectSequencePreviousValString(String sequenceName) throws MappingException

Generate the select expression fragment that will retrieve the previous value of a sequence as part of another (typically DML) statement.

This differs from getSequencePreviousValString(String) in that it must return an expression usable within another statement.

Parameters
sequenceName:String

the name of the sequence

Returns:String

The "previous value" fragment.

Exceptions
MappingException:
If sequences are not supported.
getSequenceNextValStringback to summary
public default String getSequenceNextValString(String sequenceName) throws MappingException

Generate the appropriate select statement to to retrieve the next value of a sequence.

This should be a stand alone select statement.

Parameters
sequenceName:String

the name of the sequence

Returns:String

String The select "next value" statement.

Exceptions
MappingException:
If sequences are not supported.
getSequenceNextValStringback to summary
public default String getSequenceNextValString(String sequenceName, int increment) throws MappingException

Generate the appropriate select statement to to retrieve the next value of a sequence.

This should be a stand alone select statement.

Parameters
sequenceName:String

the name of the sequence

increment:int

the increment, in case it needs to be passed explicitly

Returns:String

String The select "next value" statement.

Exceptions
MappingException:
If sequences are not supported.
getSequencePreviousValStringback to summary
public default String getSequencePreviousValString(String sequenceName) throws MappingException

Generate the appropriate select statement to to retrieve the previous value of a sequence.

This should be a stand alone select statement.

Parameters
sequenceName:String

the name of the sequence

Returns:String

String The select "previous value" statement.

Exceptions
MappingException:
If sequences are not supported.
sometimesNeedsStartingValueback to summary
public default boolean sometimesNeedsStartingValue()

Do we need to explicitly specify minvalue or maxvalue when the initial value doesn't have the same sign as the increment?

startingValueback to summary
public default String startingValue(int initialValue, int incrementSize)
supportsPooledSequencesback to summary
public default boolean supportsPooledSequences()

Does this dialect support "pooled" sequences. Not aware of a better name for this. Essentially can we specify the initial and increment values?

Returns:boolean

True if such "pooled" sequences are supported; false otherwise.

See Also
getCreateSequenceStrings(String, int, int), getCreateSequenceString(String, int, int)
supportsSequencesback to summary
public default boolean supportsSequences()

Does this dialect support sequences?

Returns:boolean

True if sequences supported; false otherwise.