Class PlatformDefaultImpl
java.lang.Object
org.apache.torque.templates.platform.PlatformDefaultImpl
- All Implemented Interfaces:
Platform
- Direct Known Subclasses:
PlatformDerbyImpl,PlatformHsqldbImpl,PlatformMssqlImpl,PlatformMysqlImpl,PlatformOracleImpl,PlatformPostgresqlImpl
Default implementation for the Platform interface.
- Version:
- $Id: PlatformDefaultImpl.java 1917240 2024-04-21 13:22:54Z tv $
- Author:
- Martin Poeschl
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether the "not null part" of the definition of a column should be generated before the "autoincrement part" in a "create table" statement.protected booleanReturns whether backslashes must be escaped in string literals.protected StringformatDateTimeString(Date date, String format) Helper function to format date values to a platform-specific string.getDateString(Date date) Formats the given date as date string which is parseable by the database.getNullString(boolean notNull) getSizeSuffix(String sqlType) Returns a possible SQL suffix for column definitions of certain SQL Types, e.g. for Oracle VARCHAR2 columns, it typically makes sense to use 'x CHAR' instead of 'x' as size.getSqlTypeForSchemaType(SchemaType schemaType) Returns the db specific SQL type for a Torque type.getTimestampString(Date date) Formats the given date as timestamp string which is parseable by the database.getTimeString(Date date) Formats the given date as time string which is parseable by the database.booleanReturns if the RDBMS-specific SQL type has a scale attribute.booleanReturns if the RDBMS-specific SQL type has a size attribute.booleanReturns whether the database has schema support unique constraint for columns with sizequoteAndEscape(String text) Quotes and escapes a string such that it can be used as literal String value in SQL.protected voidsetSchemaTypeToSqlTypeMapping(SchemaType schemaType, SqlType sqlType) Adds a mapping to the torque schema type -> sql type map.booleanReturns whether the database has schema support where a schema is not tied to a user (oracle) or database (mysql), but can be created separately.
-
Constructor Details
-
PlatformDefaultImpl
public PlatformDefaultImpl()Default constructor.
-
-
Method Details
-
setSchemaTypeToSqlTypeMapping
Adds a mapping to the torque schema type -> sql type map.- Parameters:
schemaType- the torque schema type which should be mapped, not null.sqlType- the sql type for the torque schema type, not null.
-
formatDateTimeString
Helper function to format date values to a platform-specific string. setZoneIdto GMT timezone.- Parameters:
date- the Date objectformat- the format string- Returns:
- the formatted string
-
getSqlTypeForSchemaType
Description copied from interface:PlatformReturns the db specific SQL type for a Torque type.- Specified by:
getSqlTypeForSchemaTypein interfacePlatform- Parameters:
schemaType- the Torque type, not null.- Returns:
- the db specific SQL type, or null if no SQL type is defined for the given Torque type.
- See Also:
-
getNullString
- Specified by:
getNullStringin interfacePlatform- Parameters:
notNull- flag for not null- Returns:
- Only produces a SQL fragment if null values are disallowed.
- See Also:
-
getAutoIncrement
- Specified by:
getAutoIncrementin interfacePlatform- Returns:
- The RDBMS-specific SQL fragment for autoincrement.
- See Also:
-
hasScale
Description copied from interface:PlatformReturns if the RDBMS-specific SQL type has a scale attribute. -
hasSize
Description copied from interface:PlatformReturns if the RDBMS-specific SQL type has a size attribute. -
getSizeSuffix
Returns a possible SQL suffix for column definitions of certain SQL Types, e.g. for Oracle VARCHAR2 columns, it typically makes sense to use 'x CHAR' instead of 'x' as size.- Specified by:
getSizeSuffixin interfacePlatform- Parameters:
sqlType- the SQL type to determine the suffix for.- Returns:
- The size suffix, not null. This implementation always returns the empty string.
-
createNotNullBeforeAutoincrement
public boolean createNotNullBeforeAutoincrement()Description copied from interface:PlatformReturns whether the "not null part" of the definition of a column should be generated before the "autoincrement part" in a "create table" statement.- Specified by:
createNotNullBeforeAutoincrementin interfacePlatform- Returns:
- true if the "not null part" should be first, false if the "autoincrement part" should be first in a "create table" statement.
- See Also:
-
quoteAndEscape
Description copied from interface:PlatformQuotes and escapes a string such that it can be used as literal String value in SQL.- Specified by:
quoteAndEscapein interfacePlatform- Parameters:
text- The string to escape, or null.- Returns:
- the escaped String, not null.
- See Also:
-
escapeBackslashes
protected boolean escapeBackslashes()Returns whether backslashes must be escaped in string literals.- Returns:
- true if backslashes bust be escaped, false otherwise.
-
getDateString
Formats the given date as date string which is parseable by the database.- Specified by:
getDateStringin interfacePlatform- Parameters:
date- the date to format.- Returns:
- the date string, inclusive string escaping.
-
getTimeString
Formats the given date as time string which is parseable by the database.- Specified by:
getTimeStringin interfacePlatform- Parameters:
date- the date to format.- Returns:
- the time string, inclusive string escaping.
-
getTimestampString
Formats the given date as timestamp string which is parseable by the database.- Specified by:
getTimestampStringin interfacePlatform- Parameters:
date- the date to format.- Returns:
- the timestamp string, inclusive string escaping.
-
usesStandaloneSchema
public boolean usesStandaloneSchema()Returns whether the database has schema support where a schema is not tied to a user (oracle) or database (mysql), but can be created separately.- Specified by:
usesStandaloneSchemain interfacePlatform- Returns:
- this implementation returns false.
-
hasUniqueConstraintSize
public boolean hasUniqueConstraintSize()Description copied from interface:PlatformReturns whether the database has schema support unique constraint for columns with size- Specified by:
hasUniqueConstraintSizein interfacePlatform- Returns:
- true if unique column constraint has size
-