public abstract class SqlDialect
extends java.lang.Object
ConnectionHolder
,
DataObject
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BOOLEAN_FALSE_INT |
static java.lang.String |
BOOLEAN_TRUE_INT |
protected DataObject |
dataObject |
protected java.text.SimpleDateFormat |
timestampFormat |
Constructor and Description |
---|
SqlDialect() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
compress(java.lang.String columnName,
java.lang.String columnValue)
Compresses the column value to its maximum length as specified in database.
|
protected void |
extendCreateStatement(java.lang.StringBuilder createStatement,
AbstractAttribute attribute) |
protected void |
extendInsertStatementWithValues(int i,
java.sql.PreparedStatement statementForInsertion,
java.util.HashMap<java.lang.String,java.lang.Object> original,
java.util.HashMap<java.lang.String,java.lang.Object> workedOn,
java.lang.String columnName,
int columnType,
int columnScale,
java.lang.String columnNameOfRecordingDate,
java.lang.String columnNameOfRecordingUser,
java.lang.String recordingUser) |
protected java.lang.String |
extendToLength(java.lang.String value,
int length)
Extend a String by spaces up to the length as specified to fit the minimum length of char columns as requested by e.g ucanaccess.
|
protected int |
extendUpdatePhrase(int countUpdateColumns,
java.lang.StringBuilder updateStatement,
java.util.HashMap<java.lang.String,java.lang.Object> original,
java.util.HashMap<java.lang.String,java.lang.Object> workedOn,
java.lang.String columnName,
int columnType,
int columnScale) |
void |
fillInsertStatementWithValues(java.sql.PreparedStatement statementForInsertion,
java.util.HashMap<java.lang.String,java.lang.Object> original,
java.util.HashMap<java.lang.String,java.lang.Object> workedOn,
int columnCount,
java.lang.String[] columnNames,
int[] columnType,
int[] columnScale,
java.lang.String columnNameOfRecordingDate,
java.lang.String columnNameOfRecordingUser,
java.lang.String recordingUser) |
boolean |
getBoolean(java.lang.String columnName,
java.util.HashMap<java.lang.String,java.lang.Object> original)
Returns the value of a column as boolean.
|
java.lang.String |
getCreateStatement(EntityInfo entityInfo)
Returns the specific create statement string of the specified table
|
java.lang.String |
getCreateStatement(java.lang.String tableName,
AbstractAttribute[] attributes,
Index[] indices)
Returns the specific create statement string of the specified table
|
java.lang.String |
getCreateStatement(java.lang.String tableName,
AbstractAttribute[] attributes,
Index[] indices,
ForeignKey[] foreignKeys)
Returns the specific create statement string of the specified table
|
static int |
getIntDateValue(java.sql.Date dateValue) |
protected java.lang.String |
getLimitationFragment(int limit,
int offset)
Returns the limitation fragment of the SQL statement.
|
protected boolean |
getRowBoolean(java.sql.ResultSet rs,
int columnNbr)
Returns the boolean value of the specified column.
|
protected boolean |
getRowBoolean(java.sql.ResultSet rs,
java.lang.String columnName)
Returns the boolean value of the specified column.
|
protected java.sql.Date |
getRowDate(java.sql.ResultSet rs,
int columnNbr)
Returns the date value of the specified column.
|
protected java.sql.Date |
getRowDate(java.sql.ResultSet rs,
java.lang.String columnName)
Returns the date value of the specified column.
|
protected double |
getRowDouble(java.sql.ResultSet rs,
int columnNbr)
Returns the double value of the specified column.
|
protected double |
getRowDouble(java.sql.ResultSet rs,
java.lang.String columnName)
Returns the double value of the specified column.
|
protected float |
getRowFloat(java.sql.ResultSet rs,
int columnNbr)
Returns the float value of the specified column.
|
protected float |
getRowFloat(java.sql.ResultSet rs,
java.lang.String columnName)
Returns the float value of the specified column.
|
protected int |
getRowInt(java.sql.ResultSet rs,
int columnNbr)
Returns the int value of the specified column.
|
protected int |
getRowInt(java.sql.ResultSet rs,
java.lang.String columnName)
Returns the int value of the specified column.
|
protected long |
getRowLong(java.sql.ResultSet rs,
int columnNbr)
Returns the long value of the specified column.
|
protected long |
getRowLong(java.sql.ResultSet rs,
java.lang.String columnName)
Returns the long value of the specified column.
|
protected java.lang.String |
getRowString(java.sql.ResultSet rs,
int columnNbr)
Returns the String value of the specified column.
|
protected java.lang.String |
getRowString(java.sql.ResultSet rs,
java.lang.String columnName)
Returns the String value of the specified column.
|
protected java.sql.Time |
getRowTime(java.sql.ResultSet rs,
int columnNbr)
Returns the time value of the specified column.
|
protected java.sql.Time |
getRowTime(java.sql.ResultSet rs,
java.lang.String columnName)
Returns the time value of the specified column.
|
protected java.sql.Timestamp |
getRowTimestamp(java.sql.ResultSet rs,
java.lang.String columnName)
Returns the timestamp value of the specified column.
|
java.lang.String |
getSqlCompareString(boolean b)
Returns the specific variant how boolean values are compared.
|
abstract java.lang.String |
getSqlCompareString(java.sql.Date date)
Returns the specific variant how date values are compared.
|
abstract java.lang.String |
getSqlCompareString(DateString dateString)
Returns the specific variant how date values are compared.
|
java.lang.String |
getSqlCompareString(java.sql.Timestamp timestamp) |
java.lang.String |
getSQLFormat(java.lang.Double doubleObj)
Returns a double as a string in a way it is accepted at sql updates.
|
java.lang.String |
getUpdatePhrase(java.util.HashMap<java.lang.String,java.lang.Object> original,
java.util.HashMap<java.lang.String,java.lang.Object> workedOn,
java.lang.String entity,
int columnCount,
java.lang.String[] columnNames,
int[] columnType,
int[] columnScale)
Returns the update statement string.
|
java.lang.String |
getWhereConditionFragementForExactDateComparison(java.lang.String columnName,
java.sql.Date date)
Returns the compare fragment for exact date comparison regardless their time parts in where conditions.
|
protected void |
initColumn(java.util.HashMap<java.lang.String,java.lang.Object> original,
java.util.HashMap<java.lang.String,java.lang.Object> workedOn,
java.lang.String columnName,
int columnType,
int columnScale) |
void |
initRow(java.util.HashMap<java.lang.String,java.lang.Object> original,
java.util.HashMap<java.lang.String,java.lang.Object> workedOn,
int columnCount,
java.lang.String[] columnNames,
int[] columnType,
int[] columnScale)
Initializes a row.
|
protected boolean |
isKnownAsBoolean(java.lang.String columnName)
Checks whether or not the specified column is of type boolean by
evaluating the attributes of the data object if available.
|
protected static boolean |
isPartOfUniqueIndex(java.lang.String fieldName,
Index[] indices)
Returns true if fieldName is part of one of the unique indices.
|
protected void |
loadColumn(java.sql.ResultSet rs,
java.util.HashMap<java.lang.String,java.lang.Object> original,
java.util.HashMap<java.lang.String,java.lang.Object> workedOn,
java.lang.String columnName,
int columnType,
int columnScale) |
void |
loadRow(java.sql.ResultSet rs,
java.util.HashMap<java.lang.String,java.lang.Object> original,
java.util.HashMap<java.lang.String,java.lang.Object> workedOn,
int columnCount,
java.lang.String[] columnNames,
int[] columnType,
int[] columnScale)
Loads the row's values into buffers for random access.
|
protected void |
setAttributes(AbstractAttribute[] attributes)
Sets the list of attributes.
|
void |
setBoolean(java.lang.String columnName,
boolean boolValue,
java.util.HashMap<java.lang.String,java.lang.Object> workedOn)
Sets the value of the specified column.
|
protected void |
setDataObject(DataObject dataObject) |
protected java.lang.String |
sqlSecure(java.lang.String stringField)
Replaces ' by '' to avoid SQL error while inserting or updating.
|
boolean |
supportsForeignKey() |
boolean |
supportsPrimaryKey() |
java.lang.String |
transformStringWhenSaving(java.lang.String columnName,
java.lang.String value)
Converts String values before sending to database.
|
abstract java.lang.String |
unifyColumnName(java.lang.String columnName)
Unifies the column name.
|
abstract java.lang.String |
unifyTableName(java.lang.String tableName)
Unifies the table name.
|
public static final java.lang.String BOOLEAN_TRUE_INT
public static final java.lang.String BOOLEAN_FALSE_INT
protected DataObject dataObject
protected java.text.SimpleDateFormat timestampFormat
protected static boolean isPartOfUniqueIndex(java.lang.String fieldName, Index[] indices)
fieldName
- the name of the field to checkindices
- the indices to look forprotected void setDataObject(DataObject dataObject)
public boolean supportsPrimaryKey()
public boolean supportsForeignKey()
public java.lang.String getCreateStatement(EntityInfo entityInfo)
entityInfo
- informations about the table to be createdpublic java.lang.String getCreateStatement(java.lang.String tableName, AbstractAttribute[] attributes, Index[] indices)
tableName
- the name of the table to be createdattributes
- the attribute of the table to be createdindices
- the indices to be createdpublic java.lang.String getCreateStatement(java.lang.String tableName, AbstractAttribute[] attributes, Index[] indices, ForeignKey[] foreignKeys)
tableName
- the name of the table to be createdattributes
- the attribute of the table to be createdindices
- the indices to be createdforeignKeys
- the foreign keys of the table to be createdprotected void extendCreateStatement(java.lang.StringBuilder createStatement, AbstractAttribute attribute)
public void initRow(java.util.HashMap<java.lang.String,java.lang.Object> original, java.util.HashMap<java.lang.String,java.lang.Object> workedOn, int columnCount, java.lang.String[] columnNames, int[] columnType, int[] columnScale)
original
- the buffer of original values (before changing values)workedOn
- the buffer of worked on values (after changing values)columnCount
- the number of the regarded columnscolumnNames
- the names of the regarded columnscolumnType
- the types of the regarded columnscolumnScale
- the scales of the regarded columnsprotected void initColumn(java.util.HashMap<java.lang.String,java.lang.Object> original, java.util.HashMap<java.lang.String,java.lang.Object> workedOn, java.lang.String columnName, int columnType, int columnScale)
public void loadRow(java.sql.ResultSet rs, java.util.HashMap<java.lang.String,java.lang.Object> original, java.util.HashMap<java.lang.String,java.lang.Object> workedOn, int columnCount, java.lang.String[] columnNames, int[] columnType, int[] columnScale)
rs
- the used result setoriginal
- the buffer of original values (before changing values)workedOn
- the buffer of worked on values (after changing values)columnCount
- the number of the regarded columnscolumnNames
- the names of the regarded columnscolumnType
- the types of the regarded columnscolumnScale
- the scales of the regarded columnsprotected void loadColumn(java.sql.ResultSet rs, java.util.HashMap<java.lang.String,java.lang.Object> original, java.util.HashMap<java.lang.String,java.lang.Object> workedOn, java.lang.String columnName, int columnType, int columnScale)
public void fillInsertStatementWithValues(java.sql.PreparedStatement statementForInsertion, java.util.HashMap<java.lang.String,java.lang.Object> original, java.util.HashMap<java.lang.String,java.lang.Object> workedOn, int columnCount, java.lang.String[] columnNames, int[] columnType, int[] columnScale, java.lang.String columnNameOfRecordingDate, java.lang.String columnNameOfRecordingUser, java.lang.String recordingUser) throws java.sql.SQLException
java.sql.SQLException
protected void extendInsertStatementWithValues(int i, java.sql.PreparedStatement statementForInsertion, java.util.HashMap<java.lang.String,java.lang.Object> original, java.util.HashMap<java.lang.String,java.lang.Object> workedOn, java.lang.String columnName, int columnType, int columnScale, java.lang.String columnNameOfRecordingDate, java.lang.String columnNameOfRecordingUser, java.lang.String recordingUser) throws java.sql.SQLException
java.sql.SQLException
public java.lang.String getUpdatePhrase(java.util.HashMap<java.lang.String,java.lang.Object> original, java.util.HashMap<java.lang.String,java.lang.Object> workedOn, java.lang.String entity, int columnCount, java.lang.String[] columnNames, int[] columnType, int[] columnScale)
original
- the buffer of original values (before changing values)workedOn
- the buffer of worked on values (after changing values)entity
- the table namecolumnCount
- the number of the regarded columnscolumnNames
- the names of the regarded columnscolumnType
- the types of the regarded columnscolumnScale
- the scales of the regarded columnsprotected int extendUpdatePhrase(int countUpdateColumns, java.lang.StringBuilder updateStatement, java.util.HashMap<java.lang.String,java.lang.Object> original, java.util.HashMap<java.lang.String,java.lang.Object> workedOn, java.lang.String columnName, int columnType, int columnScale)
public abstract java.lang.String unifyTableName(java.lang.String tableName)
tableName
- the table name to unifypublic abstract java.lang.String unifyColumnName(java.lang.String columnName)
columnName
- the column name to unifypublic abstract java.lang.String getSqlCompareString(DateString dateString)
dateString
- the DateString to be preparedpublic abstract java.lang.String getSqlCompareString(java.sql.Date date)
date
- the date value to be preparedpublic java.lang.String getWhereConditionFragementForExactDateComparison(java.lang.String columnName, java.sql.Date date)
columnName
- the name of the column containing the date value (which may include time parts!)date
- the date to compare topublic java.lang.String getSqlCompareString(java.sql.Timestamp timestamp)
public java.lang.String getSqlCompareString(boolean b)
b
- the boolean value to be preparedpublic boolean getBoolean(java.lang.String columnName, java.util.HashMap<java.lang.String,java.lang.Object> original)
columnName
- the name of the columnoriginal
- the buffer of original values of the rowpublic void setBoolean(java.lang.String columnName, boolean boolValue, java.util.HashMap<java.lang.String,java.lang.Object> workedOn)
columnName
- the name of the column to be setboolValue
- the value the column shall be set toworkedOn
- the buffer of worked on values of the rowpublic java.lang.String transformStringWhenSaving(java.lang.String columnName, java.lang.String value)
value
- the value to transformprotected boolean getRowBoolean(java.sql.ResultSet rs, int columnNbr)
rs
- the result setcolumnNbr
- the number of the columnprotected float getRowFloat(java.sql.ResultSet rs, int columnNbr)
rs
- the result setcolumnNbr
- the number of the columnprotected int getRowInt(java.sql.ResultSet rs, int columnNbr)
rs
- the result setcolumnNbr
- the number of the columnprotected long getRowLong(java.sql.ResultSet rs, int columnNbr)
rs
- the result setcolumnNbr
- the number of the columnprotected java.sql.Date getRowDate(java.sql.ResultSet rs, int columnNbr)
rs
- the result setcolumnNbr
- the number of the columnprotected java.sql.Time getRowTime(java.sql.ResultSet rs, int columnNbr)
rs
- the result setcolumnNbr
- the number of the columnprotected java.lang.String getRowString(java.sql.ResultSet rs, int columnNbr)
rs
- the result setcolumnNbr
- the number of the columnprotected double getRowDouble(java.sql.ResultSet rs, int columnNbr)
rs
- the result setcolumnNbr
- the number of the columnprotected boolean getRowBoolean(java.sql.ResultSet rs, java.lang.String columnName)
rs
- the result setcolumnName
- the name of the columnprotected float getRowFloat(java.sql.ResultSet rs, java.lang.String columnName)
rs
- the result setcolumnName
- the name of the columnprotected int getRowInt(java.sql.ResultSet rs, java.lang.String columnName)
rs
- the result setcolumnName
- the name of the columnprotected long getRowLong(java.sql.ResultSet rs, java.lang.String columnName)
rs
- the result setcolumnName
- the name of the columnprotected java.sql.Date getRowDate(java.sql.ResultSet rs, java.lang.String columnName)
rs
- the result setcolumnName
- the name of the columnprotected java.sql.Time getRowTime(java.sql.ResultSet rs, java.lang.String columnName)
rs
- the result setcolumnName
- the name of the columnprotected java.sql.Timestamp getRowTimestamp(java.sql.ResultSet rs, java.lang.String columnName)
rs
- the result setcolumnName
- the name of the columnprotected java.lang.String getRowString(java.sql.ResultSet rs, java.lang.String columnName)
rs
- the result setcolumnName
- the name of the columnprotected double getRowDouble(java.sql.ResultSet rs, java.lang.String columnName)
rs
- the result setcolumnName
- the name of the columnpublic java.lang.String getSQLFormat(java.lang.Double doubleObj)
doubleObj
- the double value to be formattedprotected java.lang.String sqlSecure(java.lang.String stringField)
stringField
- the String to modifyprotected java.lang.String extendToLength(java.lang.String value, int length)
value
- the value to be extendedlength
- the required length of the char columnprotected java.lang.String compress(java.lang.String columnName, java.lang.String columnValue)
columnName
- the name of the column to be compressedcolumnValue
- the column value to be compressedprotected java.lang.String getLimitationFragment(int limit, int offset)
limit
- maximum of entries to be put into the result setoffset
- the number of records that don't have to be read anymoreprotected void setAttributes(AbstractAttribute[] attributes)
the
- attributes of the data object.protected boolean isKnownAsBoolean(java.lang.String columnName)
columnName
- the name of the column to be checked as boolean typepublic static int getIntDateValue(java.sql.Date dateValue)
Copyright 1998-2023 Christoph Mueller, Kaerntner Str. 56, D-70469 Stuttgart, Germany, https://www.perpus.de