public abstract class GeneratorDialect extends Object
Modifier and Type | Field and Description |
---|---|
static Date |
NOW
Represents the constant for writing the "now" function to SQL.
|
Constructor and Description |
---|
GeneratorDialect() |
Modifier and Type | Method and Description |
---|---|
protected void |
addQuotedCharacter(StringBuilder result,
char c)
Adds a quoted character to the result string buffer.
|
List<? extends EntityStatement> |
adjustNextIdentityValue(String tableName,
String columnName,
long nextValue)
Adjusts the next value of the given identity column to ensure that it is bigger than the last generated value.
|
List<? extends EntityStatement> |
adjustNextSequenceValue(String sequenceName,
long currentSequenceValue,
long nextSequenceValue,
int incrementSize)
Adjusts the given sequence to ensure that the next value is exactly the given value.
|
String |
buildCurrentSequenceValue(String sequence,
int incrementSize)
Builds the SQL expression that is used for referencing the current value of the given sequence.
|
String |
buildNextSequenceValue(String sequence,
int incrementSize)
Builds the SQL expression resp. statement that is used for creating the next value of the given sequence.
|
String |
convertBooleanValue(boolean value)
Converts a boolean value for the current database type.
|
String |
convertTemporalValue(Date value,
javax.persistence.TemporalType type)
Converts a date to an appropriate SQL expression.
|
String |
createBlobExpression(byte[] blob)
Converts the given byte array to an SQL expression for the current database.
|
protected String |
createHexBlobExpression(String prefix,
byte[] blob,
String suffix)
Creates the hex presentation of the given blob.
|
String |
createSql(EntityStatement stmt)
Creates an SQL statement from the given insert statement.
|
javax.persistence.GenerationType |
getAutoGenerationType()
Resolves the GenerationType used, if
GenerationType.AUTO is set for a GeneratedValue . |
String |
getOptionalTable()
Returns the string to use when no table is required, e.g. for "SELECT 1, 2 FROM DUAL" this would return "FROM
DUAL".
|
boolean |
isEmptyStringEqualToNull()
Indicates that the empty string is equal to
null in this database. |
boolean |
isIdentitySupported()
Indicates that identity columns are supported by the database.
|
boolean |
isNextSequenceValueInInsertSupported()
Indicates that a sequence may be updated in the insert statement.
|
boolean |
isSequenceInWhereSupported()
Indicates that references to sequences in
WHERE expressions are supported. |
boolean |
isSequenceSupported()
Indicates that sequences are supported by the database.
|
String |
quoteString(String value)
Quotes the given string.
|
public static final Date NOW
protected void addQuotedCharacter(StringBuilder result, char c)
result
- the current result bufferc
- the character to quotepublic List<? extends EntityStatement> adjustNextIdentityValue(String tableName, String columnName, long nextValue)
tableName
- the name of the table of the columncolumnName
- the name of the (auto increment) identity columnnextValue
- the next value of the identity columnpublic List<? extends EntityStatement> adjustNextSequenceValue(String sequenceName, long currentSequenceValue, long nextSequenceValue, int incrementSize)
sequenceName
- the name of the sequencecurrentSequenceValue
- the current value of the sequencenextSequenceValue
- the next value of the sequenceincrementSize
- the increment size of the sequencepublic String buildCurrentSequenceValue(String sequence, int incrementSize)
sequence
- the name of the sequenceincrementSize
- the expected incrementSize, as given in the schema - used by some dialects to ensure that exactly that
inrement is usedpublic String buildNextSequenceValue(String sequence, int incrementSize)
isNextSequenceValueInInsertSupported()
this will return an expression or a statement.sequence
- the name of the sequenceincrementSize
- the expected incrementSize, as given in the schema - used by some dialects to ensure that exactly that
inrement is usedpublic String convertBooleanValue(boolean value)
value
- the value to convertpublic String convertTemporalValue(Date value, javax.persistence.TemporalType type)
value
- the timestamp valuetype
- the typepublic String createBlobExpression(byte[] blob)
blob
- the bytes to convertprotected String createHexBlobExpression(String prefix, byte[] blob, String suffix)
prefix
- the prefix to add to the hexblob
- the binary blob to convertsuffix
- the suffix to add to the hexpublic String createSql(EntityStatement stmt)
EntityStatement.toString()
is returned, but some dialects could change database specific
things.stmt
- contains the table and all column valuespublic javax.persistence.GenerationType getAutoGenerationType()
GenerationType.AUTO
is set for a GeneratedValue
.GenerationType.AUTO
for the current dialect in Hibernate.public String getOptionalTable()
public boolean isEmptyStringEqualToNull()
null
in this database.
Important for NotNull
constraints, where an empty string would result in the same constraint violation.true
if this database assumes that an empty string is the same as null
public boolean isIdentitySupported()
true
if the database supports identitiespublic boolean isNextSequenceValueInInsertSupported()
true
to indicate that buildNextSequenceValue(String,int)
will return an expression that
may be used in an INSERT statement, false
to indicate that
buildNextSequenceValue(String,int)
returns a full statementpublic boolean isSequenceInWhereSupported()
WHERE
expressions are supported.true
if this database supports sequences in WHERE
expressionspublic boolean isSequenceSupported()
true
if the database supports sequencesCopyright © 2016 fastnate.org. All rights reserved.