public abstract class GeneratorDialect extends Object
Modifier and Type | Field and Description |
---|---|
private char[] |
letter |
static Date |
NOW
Deprecated.
Use
RelativeDate.NOW instead |
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.
|
void |
adjustNextIdentityValue(StatementsWriter writer,
GeneratorTable table,
GeneratorColumn column,
long nextValue)
Adjusts the next value of the given identity column to ensure that it is bigger than the last generated value.
|
void |
adjustNextSequenceValue(StatementsWriter writer,
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,
boolean firstCall)
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 to an SQL expression for the current database type.
|
String |
convertNumberValue(Number value)
Converts a numeric value to an SQL expression for the current database type.
|
protected String |
convertTemporalValue(Date sqlDate)
Builds the SQL expression for a date / time / timestamp.
|
String |
convertTemporalValue(Date value,
javax.persistence.TemporalType type)
Converts a date to an appropriate SQL expression.
|
Date |
convertToDatabaseDate(Date value,
javax.persistence.TemporalType type)
|
protected String |
createAddDateExpression(String referenceDate,
long value,
String unit)
Creates an SQL expression to add a value to a date.
|
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.
|
private static void |
finishPart(StringBuilder result,
String value,
int start,
int end,
boolean isOpen,
boolean close,
String concatOperator) |
javax.persistence.GenerationType |
getAutoGenerationType()
Resolves the GenerationType used, if
GenerationType.AUTO is set for a GeneratedValue . |
String |
getConcatOperator()
The operator used to concat two Strings.
|
Object |
getEmptyValuesExpression()
The SQL expression to use in an empty insert statement.
|
char[] |
getLetter() |
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 |
isEmulatingSequences()
Indicates that tables are used in place of sequences, if
GenerationType.SEQUENCE is defined for a
GeneratedValue . |
boolean |
isFastInTransaction()
Indicates that the database usually faster when all statements are executed within an transaction.
|
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 |
isSelectFromSameTableInInsertSupported()
Indicates that this dialect may select from the same table in a select.
|
boolean |
isSequenceInWhereSupported()
Indicates that references to sequences in
WHERE expressions are supported. |
boolean |
isSequenceSupported()
Indicates that sequences are supported by the database.
|
boolean |
isSettingIdentityAllowed()
Indicates if this dialect supports writing absolute values to an
GenerationType.IDENTITY column. |
String |
quoteString(String value)
Quotes the given string.
|
void |
truncateTable(StatementsWriter writer,
GeneratorTable table)
Adds a "truncate table" statement to the given writer.
|
@Deprecated public static final Date NOW
RelativeDate.NOW
insteadprivate final char[] letter
private static void finishPart(StringBuilder result, String value, int start, int end, boolean isOpen, boolean close, String concatOperator)
protected void addQuotedCharacter(StringBuilder result, char c)
result
- the current result bufferc
- the character to quotepublic void adjustNextIdentityValue(StatementsWriter writer, GeneratorTable table, GeneratorColumn column, long nextValue) throws IOException
writer
- the target of any generated statementtable
- the table of the columncolumn
- the (auto increment) identity columnnextValue
- the next value of the identity columnIOException
- if the writer throws onepublic void adjustNextSequenceValue(StatementsWriter writer, String sequenceName, long currentSequenceValue, long nextSequenceValue, int incrementSize) throws IOException
writer
- the target of the generated statementssequenceName
- the fully qualified name of the sequencecurrentSequenceValue
- the current value of the sequencenextSequenceValue
- the next value of the sequenceincrementSize
- the increment size of the sequenceIOException
- if the writer throws onepublic String buildCurrentSequenceValue(String sequence, int incrementSize, boolean firstCall)
sequence
- the fully qualified name of the sequenceincrementSize
- the expected incrementSize, as given in the schema - used by some dialects to ensure that exactly that
inrement is usedfirstCall
- indicates that the sequence was not updated before in this session - we may need to use a different
approach to get the current valuepublic String buildNextSequenceValue(String sequence, int incrementSize)
isNextSequenceValueInInsertSupported()
this will return an expression or a statement.sequence
- the fully qualified 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 convertNumberValue(Number value)
value
- the numeric valueprotected String convertTemporalValue(Date sqlDate)
sqlDate
- the date, already converted to one from javax.sql.*
public String convertTemporalValue(Date value, javax.persistence.TemporalType type)
value
- the timestamp valuetype
- the typepublic Date convertToDatabaseDate(Date value, javax.persistence.TemporalType type)
value
- the Java-Date objecttype
- the type of the conversionprotected String createAddDateExpression(String referenceDate, long value, String unit)
referenceDate
- the expression for the reference datevalue
- the value to add to the dateunit
- the unit of the valuepublic 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 javax.persistence.GenerationType getAutoGenerationType()
GenerationType.AUTO
is set for a GeneratedValue
.GenerationType.AUTO
for the current dialect in Hibernate.public String getConcatOperator()
null
if this dialect does not have such an operatorpublic Object getEmptyValuesExpression()
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 isEmulatingSequences()
GenerationType.SEQUENCE
is defined for a
GeneratedValue
.true
if sequences are emulated with tables, false
if sequences are supportedpublic boolean isFastInTransaction()
true
if an transaction is faster than auto commitpublic 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 isSelectFromSameTableInInsertSupported()
true
if "INSERT INTO XXX (a) VALUES (SELECT max(a) FROM XXX)" is supportedpublic boolean isSequenceInWhereSupported()
WHERE
expressions are supported.true
if this database supports sequences in WHERE
expressionspublic boolean isSequenceSupported()
true
if the database supports sequencespublic boolean isSettingIdentityAllowed()
GenerationType.IDENTITY
column.true
if we can write fix values for identity columnspublic String quoteString(String value)
value
- the value to quotepublic void truncateTable(StatementsWriter writer, GeneratorTable table) throws IOException
writer
- the target of the statementtable
- the table to truncateIOException
- if the writer throws one@Generated(value="lombok") public char[] getLetter()
Copyright © 2022 fastnate.org. All rights reserved.