Package org.fastnate.generator.dialect
Class OracleDialect
java.lang.Object
org.fastnate.generator.dialect.GeneratorDialect
org.fastnate.generator.dialect.OracleDialect
Handles Oracle specific conversions.
- Author:
- Tobias Liefke
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final intFields inherited from class org.fastnate.generator.dialect.GeneratorDialect
NOW -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadjustNextSequenceValue(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.buildCurrentSequenceValue(String sequence, int incrementSize, boolean firstCall) Builds the SQL expression that is used for referencing the current value of the given sequence.buildNextSequenceValue(String sequence, int incrementSize) Builds the SQL expression resp. statement that is used for creating the next value of the given sequence.convertTemporalValue(Date value, jakarta.persistence.TemporalType type) Converts a date to an appropriate SQL expression.protected StringcreateAddDateExpression(String referenceDate, long value, String unit) Creates an SQL expression to add a value to a date.createBlobExpression(byte[] blob) Converts the given byte array to an SQL expression for the current database.Returns the string to use when no table is required, e.g. for "SELECT 1, 2 FROM DUAL" this would return "FROM DUAL".booleanIndicates that the empty string is equal tonullin this database.booleanIndicates that the database usually faster when all statements are executed within an transaction.booleanIndicates that identity columns are supported by the database.booleanIndicates that references to sequences inWHEREexpressions are supported.quoteString(String value) Quotes the given string.Methods inherited from class org.fastnate.generator.dialect.GeneratorDialect
addQuotedCharacter, adjustNextIdentityValue, convertBooleanValue, convertNumberValue, convertTemporalValue, convertToDatabaseDate, createHexBlobExpression, getConcatOperator, getEmptyValuesExpression, getLetter, isEmulatingSequences, isNextSequenceValueInInsertSupported, isSchemaSupported, isSelectFromSameTableInInsertSupported, isSequenceSupported, isSettingIdentityAllowed, quoteIdentifier, truncateTable
-
Field Details
-
MAX_VARCHAR_LENGTH
private static final int MAX_VARCHAR_LENGTH- See Also:
-
MAX_BLOB_LENGTH
private static final int MAX_BLOB_LENGTH- See Also:
-
-
Constructor Details
-
OracleDialect
public OracleDialect()
-
-
Method Details
-
adjustNextSequenceValue
public void adjustNextSequenceValue(StatementsWriter writer, String sequenceName, long currentSequenceValue, long nextSequenceValue, int incrementSize) throws IOException Description copied from class:GeneratorDialectAdjusts the given sequence to ensure that the next value is exactly the given value.- Overrides:
adjustNextSequenceValuein classGeneratorDialect- Parameters:
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 sequence- Throws:
IOException- if the writer throws one
-
buildCurrentSequenceValue
Description copied from class:GeneratorDialectBuilds the SQL expression that is used for referencing the current value of the given sequence.- Overrides:
buildCurrentSequenceValuein classGeneratorDialect- Parameters:
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 value- Returns:
- the SQL expression to use in statement
-
buildNextSequenceValue
Description copied from class:GeneratorDialectBuilds the SQL expression resp. statement that is used for creating the next value of the given sequence. Depending onGeneratorDialect.isNextSequenceValueInInsertSupported()this will return an expression or a statement.- Overrides:
buildNextSequenceValuein classGeneratorDialect- Parameters:
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 used- Returns:
- the SQL to use in resp. before the insert / update statement
-
convertTemporalValue
Description copied from class:GeneratorDialectConverts a date to an appropriate SQL expression.- Overrides:
convertTemporalValuein classGeneratorDialect- Parameters:
value- the timestamp valuetype- the type- Returns:
- SQL expression representing the value.
-
createAddDateExpression
Description copied from class:GeneratorDialectCreates an SQL expression to add a value to a date.- Overrides:
createAddDateExpressionin classGeneratorDialect- Parameters:
referenceDate- the expression for the reference datevalue- the value to add to the dateunit- the unit of the value- Returns:
- the SQL expression that adds the value
-
createBlobExpression
Description copied from class:GeneratorDialectConverts the given byte array to an SQL expression for the current database.- Overrides:
createBlobExpressionin classGeneratorDialect- Parameters:
blob- the bytes to convert- Returns:
- the expression for the bytes
-
getOptionalTable
Description copied from class:GeneratorDialectReturns the string to use when no table is required, e.g. for "SELECT 1, 2 FROM DUAL" this would return "FROM DUAL".- Overrides:
getOptionalTablein classGeneratorDialect- Returns:
- the SQL to use in "SELECT x [OPTIONALTABLE] WHERE ..."
-
isEmptyStringEqualToNull
public boolean isEmptyStringEqualToNull()Description copied from class:GeneratorDialectIndicates that the empty string is equal tonullin this database. Important forNotNullconstraints, where an empty string would result in the same constraint violation.- Overrides:
isEmptyStringEqualToNullin classGeneratorDialect- Returns:
trueif this database assumes that an empty string is the same asnull
-
isFastInTransaction
public boolean isFastInTransaction()Description copied from class:GeneratorDialectIndicates that the database usually faster when all statements are executed within an transaction. For example Oracle is approx. 25% faster but H2 is 200% slower compared to auto commit. Only relevant if executed against a running database.- Overrides:
isFastInTransactionin classGeneratorDialect- Returns:
trueif an transaction is faster than auto commit
-
isIdentitySupported
public boolean isIdentitySupported()Description copied from class:GeneratorDialectIndicates that identity columns are supported by the database.- Overrides:
isIdentitySupportedin classGeneratorDialect- Returns:
trueif the database supports identities
-
isSequenceInWhereSupported
public boolean isSequenceInWhereSupported()Description copied from class:GeneratorDialectIndicates that references to sequences inWHEREexpressions are supported.- Overrides:
isSequenceInWhereSupportedin classGeneratorDialect- Returns:
trueif this database supports sequences inWHEREexpressions
-
quoteString
Description copied from class:GeneratorDialectQuotes the given string.- Overrides:
quoteStringin classGeneratorDialect- Parameters:
value- the value to quote- Returns:
- the quoted string
-