public abstract class TempTableHelper
extends java.lang.Object
sqlTempTableCreate(com.goldencode.p2j.persist.Database, java.lang.Class<? extends com.goldencode.p2j.persist.DataModelObject>)
- gets a dialect-specific SQL statement
to create a particular temp table.
sqlTempTableDrop(com.goldencode.p2j.persist.Database, java.lang.Class<? extends com.goldencode.p2j.persist.DataModelObject>)
- gets a dialect-specific SQL statement
to drop a particular temp table.
sqlTempTableIndexCreate(com.goldencode.p2j.persist.Database, java.lang.Class<? extends com.goldencode.p2j.persist.DataModelObject>)
- gets a list of dialect-specific
SQL statements to create indexes for a particular temp table.
sqlTempTableIndexDrop(com.goldencode.p2j.persist.Database, java.lang.Class<? extends com.goldencode.p2j.persist.DataModelObject>)
- gets a list of dialect-specific
SQL statements to drop indexes for a particular temp table.
Modifier and Type | Field and Description |
---|---|
private static java.util.Map<java.lang.Class<?>,TempTableHelper> |
cache
Map of DMO interfaces to helper objects
|
protected Database |
database
The used database
|
private java.lang.Class<? extends DataModelObject> |
dmoIface
DMO interface which provides the public API to the temp table
|
private java.lang.String |
implicitIndexName
The implicit index name for this table (the primary index, first in alphabetical order or 'recid').
|
private java.lang.String |
implicitSqlIndexName
The implicit SQL index name for this table (the primary index, first in alphabetical order or 'recid').
|
private static java.util.logging.Logger |
LOG
Logger
|
protected java.lang.String |
schema
Name of table schema
|
private java.util.List<java.lang.String> |
sqlCreateIndexes
Dialect-specific SQL statement(s) to create temp table index(es)
|
private java.util.List<java.lang.String> |
sqlCreateTables
Dialect-specific SQL statement(s) to create temp table(s)
|
private java.util.List<java.lang.String> |
sqlDropIndexes
Dialect-specific SQL statement(s) to drop temp table index(es)
|
private java.util.List<java.lang.String> |
sqlDropTables
Dialect-specific SQL statement(s) to drop temp table(s)
|
static java.lang.String |
UNIQUE_SUFFIX_KEY
Key which will be replaced by a unique suffix in certain DDL
|
Constructor and Description |
---|
TempTableHelper(java.lang.Class<? extends DataModelObject> dmoIface,
Database database)
Constructor.
Generates the full set of DDL statement(s) for creating the backing table, including indexes for the dialect of the specified database and store them in private final members. |
Modifier and Type | Method and Description |
---|---|
(package private) static TempTableHelper |
get(Database database,
java.lang.Class<? extends DataModelObject> dmoIface)
Factory method for obtaining a helper.
|
(package private) abstract java.lang.String |
getAdditionalIndexSuffix()
Abstract method which will return the an additional index suffix (to
make the index unique across sessions), if needed.
|
(package private) abstract java.lang.String |
getCreateTableStatement()
Abstract method which will return the needed create table string:
"create local temporary table" or "create temporary table".
|
static java.lang.String |
getImplicitIndexName(Database database,
java.lang.Class<? extends DataModelObject> dmoIface)
Get the
implicitIndexName . |
static java.lang.String |
getImplicitSqlIndexName(Database database,
java.lang.Class<? extends DataModelObject> dmoIface)
Get the
implicitSqlIndexName . |
(package private) abstract java.util.Iterator<P2JIndex> |
getIndexes(java.lang.String schema,
java.lang.Class<? extends DataModelObject> dmoIface)
Abstract method which will return the indexes associated with a certain DMO.
|
(package private) static java.lang.String |
getTableName(java.lang.Class<? extends DataModelObject> dmoIface)
Get the backing temp table name associated with the given DMO interface, primarily for
debugging and error reporting purposes.
|
(package private) abstract boolean |
isNotNullAllowed()
Indicate whether non-nullable columns are permitted.
|
static java.util.Iterator<java.lang.String> |
sqlTempTableCreate(Database database,
java.lang.Class<? extends DataModelObject> dmoIface)
Return the SQL statement text used to create a temporary table for the
given DMO class, using the specified database dialect.
|
static java.util.Iterator<java.lang.String> |
sqlTempTableDrop(Database database,
java.lang.Class<? extends DataModelObject> dmoIface)
Return the SQL statement text used to drop a temporary table for the
given DMO class, using the specified database dialect.
|
static java.util.Iterator<java.lang.String> |
sqlTempTableIndexCreate(Database database,
java.lang.Class<? extends DataModelObject> dmoIface)
Return a list of SQL statements used to create the indexes for a
temporary table for the given DMO class, using the specified database
dialect.
|
static java.util.Iterator<java.lang.String> |
sqlTempTableIndexDrop(Database database,
java.lang.Class<? extends DataModelObject> dmoIface)
Return a list of SQL statements used to drop the indexes for a
temporary table for the given DMO class, using the specified database
dialect.
|
public static final java.lang.String UNIQUE_SUFFIX_KEY
private static final java.util.logging.Logger LOG
private static final java.util.Map<java.lang.Class<?>,TempTableHelper> cache
protected final java.lang.String schema
protected final Database database
private final java.util.List<java.lang.String> sqlCreateTables
private final java.util.List<java.lang.String> sqlDropTables
private final java.util.List<java.lang.String> sqlCreateIndexes
private final java.util.List<java.lang.String> sqlDropIndexes
private final java.lang.Class<? extends DataModelObject> dmoIface
private final java.lang.String implicitSqlIndexName
private final java.lang.String implicitIndexName
TempTableHelper(java.lang.Class<? extends DataModelObject> dmoIface, Database database)
dmoIface
- DMO interface which provides the public API to the temp table.database
- The database for which we generate the DDLs.public static java.util.Iterator<java.lang.String> sqlTempTableCreate(Database database, java.lang.Class<? extends DataModelObject> dmoIface)
database
- The dmoIface
's backing database.dmoIface
- DMO interface which represents the temp table.java.lang.RuntimeException
- if any error occurs generating the SQL statement. This will
generally indicate a configuration problem, rather than a
condition which should be handled by application code.public static java.util.Iterator<java.lang.String> sqlTempTableDrop(Database database, java.lang.Class<? extends DataModelObject> dmoIface)
database
- The dmoIface
's backing database.dmoIface
- DMO interface which represents the temp table.public static java.util.Iterator<java.lang.String> sqlTempTableIndexCreate(Database database, java.lang.Class<? extends DataModelObject> dmoIface)
database
- The dmoIface
's backing database.dmoIface
- DMO interface which represents the temp table.java.lang.RuntimeException
- if any error occurs generating the SQL statements. This will
generally indicate a configuration problem, rather than a
condition which should be handled by application code.public static java.util.Iterator<java.lang.String> sqlTempTableIndexDrop(Database database, java.lang.Class<? extends DataModelObject> dmoIface)
database
- The dmoIface
's backing database.dmoIface
- DMO interface which represents the temp table.java.lang.RuntimeException
- if any error occurs generating the SQL statements. This will
generally indicate a configuration problem, rather than a
condition which should be handled by application code.public static java.lang.String getImplicitIndexName(Database database, java.lang.Class<? extends DataModelObject> dmoIface)
implicitIndexName
.database
- The dmoIface
's backing database.dmoIface
- DMO interface which represents the temp table.public static java.lang.String getImplicitSqlIndexName(Database database, java.lang.Class<? extends DataModelObject> dmoIface)
implicitSqlIndexName
.database
- The dmoIface
's backing database.dmoIface
- DMO interface which represents the temp table.static java.lang.String getTableName(java.lang.Class<? extends DataModelObject> dmoIface)
dmoIface
- DMO interface for which a table name is needed.static TempTableHelper get(Database database, java.lang.Class<? extends DataModelObject> dmoIface)
If the associated database is the database
, an instance of class LocalTempTableHelper
will be
returned. Else, an instance of class DirtyTempTableHelper
will
be returned.
database
- The dmoIface
's backing database.dmoIface
- DMO interface which provides the public API to the temp table.abstract java.lang.String getCreateTableStatement()
abstract java.lang.String getAdditionalIndexSuffix()
abstract java.util.Iterator<P2JIndex> getIndexes(java.lang.String schema, java.lang.Class<? extends DataModelObject> dmoIface)
schema
- The schema used for this DMO.dmoIface
- The DMO for which to retrieve the indexes.abstract boolean isNotNullAllowed()
true
if non-nullable columns are permitted, else false
.