com.antelmann.sql
Class MySqlQueryToViewMapper<T extends DBEntry>
java.lang.Object
com.antelmann.sql.BaseRowMapper<T>
com.antelmann.sql.MySqlQueryToViewMapper<T>
- All Implemented Interfaces:
- TransactionRequired, MappingInfo, ObjectRowMapper<T>, Converter<RowItem,T>
public abstract class MySqlQueryToViewMapper<T extends DBEntry>
- extends BaseRowMapper<T>
enables the automated use of views with MySQL for better performance
- Since:
- 01.09.2016, 15:54:27
- Author:
- holger
- See Also:
setTableQuery(String),
checkMySqlViewForQuery(BaseRowMapper, String)
|
Field Summary |
static boolean |
enabled
|
|
Constructor Summary |
MySqlQueryToViewMapper(Database<Connection> db,
MappingInfo mi,
IDFactory idFactory,
Class<T> type,
Object... topics)
|
MySqlQueryToViewMapper(Database<Connection> db,
String tableName,
String idColumn)
|
MySqlQueryToViewMapper(Database<Connection> db,
String tableName,
String idColumn,
IDFactory idFactory,
Class<T> type)
|
MySqlQueryToViewMapper(Database<Connection> db,
String tableName,
String idColumn,
String displayColumn)
|
MySqlQueryToViewMapper(Database<Connection> db,
String tableName,
String idColumn,
String displayColumn,
IDFactory idFactory,
Class<T> type)
|
MySqlQueryToViewMapper(Database<Connection> db,
String tableName,
String idColumn,
String displayColumn,
IDFactory idFactory,
Class<T> type,
String query)
|
| Methods inherited from class com.antelmann.sql.BaseRowMapper |
addColumnsForTopic, applyFromMapping, checkExistence, convert, convertBack, convertTopicFilter, emptyStringsToNull, extractReference, extractStub, extractStub, generateNewID, generateRowProperties, getAll, getColumnDisplayMapping, getColumnNames, getColumnsForTopic, getColumnSize, getConnection, getConnectionHelper, getDisplayColumn, getDisplayNameForColumn, getEntryClass, getEntryClassMapper, getIDColumn, getIDFactory, getMappedValue, getMappingForTopic, getNextIntID, getNextIntIDFactory, getNextIntIDFactory, getPreStoreFilter, getReadOnlyColumns, getRestrictMappedColumns, getResultSet, getSQLTypeforColumn, getStubColumns, getStubQuery, getStubResultSet, getSupportedTopicColumns, getTableColumnNames, getTableName, getTableQuery, getTableQueryForComboFilter, getTransactionCounter, getUniqueRandomString, handleAfterStore, initMapping, isMappedTopic, isTranslate, javaToSql, javaToSql, lockTable, mapReference, mapReference, mapToRow, removeColumnTopic, setColumnsForTopic, setDisplayColumn, setEntryClass, setEntryClassMapper, setIDFactory, setMappedValue, setNextIntIdAsFactory, setPreStoreFilter, setReadOnlyColumns, setRestrictedMappedColumns, setStubQuery, setTableQuery, setTopic, setTranslate, sqlToJava, toSQLMap, verifyBeforeDelete, verifyBeforeStore |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
enabled
public static boolean enabled
MySqlQueryToViewMapper
public MySqlQueryToViewMapper(Database<Connection> db,
MappingInfo mi,
IDFactory idFactory,
Class<T> type,
Object... topics)
throws DatabaseException
- Throws:
DatabaseException
MySqlQueryToViewMapper
public MySqlQueryToViewMapper(Database<Connection> db,
String tableName,
String idColumn,
IDFactory idFactory,
Class<T> type)
throws DatabaseException
- Throws:
DatabaseException
MySqlQueryToViewMapper
public MySqlQueryToViewMapper(Database<Connection> db,
String tableName,
String idColumn,
String displayColumn,
IDFactory idFactory,
Class<T> type,
String query)
throws DatabaseException
- Throws:
DatabaseException
MySqlQueryToViewMapper
public MySqlQueryToViewMapper(Database<Connection> db,
String tableName,
String idColumn,
String displayColumn,
IDFactory idFactory,
Class<T> type)
throws DatabaseException
- Throws:
DatabaseException
MySqlQueryToViewMapper
public MySqlQueryToViewMapper(Database<Connection> db,
String tableName,
String idColumn,
String displayColumn)
throws DatabaseException
- Throws:
DatabaseException
MySqlQueryToViewMapper
public MySqlQueryToViewMapper(Database<Connection> db,
String tableName,
String idColumn)
throws DatabaseException
- Throws:
DatabaseException
setTableQuery
public void setTableQuery(String tableQuery)
throws DatabaseException
- Description copied from class:
BaseRowMapper
- allows to set a query for mapping the data instead of just using the table name.
This method calls
BaseRowMapper.initMapping() after setting the data.
Since a query of the form '(select ...) as t1' may not be query optimized in certain
databases, this implementation also supports a plain select statement to act as a query.
- Overrides:
setTableQuery in class BaseRowMapper<T extends DBEntry>
- Throws:
DatabaseException- See Also:
checkMySqlViewForQuery(BaseRowMapper, String)
checkMySqlViewForQuery
public static String checkMySqlViewForQuery(BaseRowMapper<?> mapper,
String tableQuery)
throws DatabaseException
- checks whether an appropriate view already exists for the given mapper
and creates one based on the given query if it doesn't exist.
If a view with the derived name for this mapper already exists, it is assumed that
this is the appropriate view that already holds the correct query for this purpose.
You can always easily regenerate all views by deleting the view names in question.
Note that the described mechanism can be circumvented by disabling this class.
- Parameters:
mapper - denotes the mapper this operation applies totableQuery - the query string that will be used to create the view if it doesn't already exist
- Returns:
- the name of the view to be used when setting the table query for the super class
- Throws:
DatabaseException- See Also:
setEnabled(boolean),
setTableQuery(String)
isEnabled
public static boolean isEnabled()
setEnabled
public static void setEnabled(boolean enabled)
- allows to globally disable the use/creation of views
trimIfApplicable
public static String trimIfApplicable(String columnName)
deleteAssociatedViews
public static int deleteAssociatedViews(Database<Connection> db)
throws SQLException
- Throws:
SQLException
(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads