|
SRJRCFrames v0.1.296 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.schwarzrot.data.access.support.AbstractDbUtils
public abstract class AbstractDbUtils
common implementation of DbUtil
and base class for database specific
utility classes. This class is used to generate SQL used at JDBC-layer.
Field Summary | |
---|---|
protected static Map<String,Integer> |
skipList
|
Fields inherited from interface de.schwarzrot.data.access.support.DbUtil |
---|
EMPTY_STRING, ONE_SPACE, PK_NAME |
Constructor Summary | |
---|---|
AbstractDbUtils()
|
Method Summary | ||
---|---|---|
Collection<ColumnMetaData> |
columnDefinitions(Connection conn,
TableDefinition td)
|
|
protected String |
createColumnDef(ColumnDefinition col)
|
|
protected void |
dumpRS(ResultSet rs)
|
|
String |
genAccessRightsForPK(TableDefinition tbInfo,
String defaultUser)
generates a SQL-string to grant access to an external sequence |
|
protected abstract String |
genAutoIncrement(ColumnDefinition cd)
|
|
String |
genColumnCreation(ColumnDefinition cd)
generates a SQL string to add a column to an existing table |
|
String |
genColumnModification(ColumnDefinition cd)
generates a SQL string to modify a column of an existing table |
|
String |
genCondition(EntityDescriptor ed,
Collection<ConditionElement> args)
generates a condition string for SQL statements |
|
|
genCondition(EntityDescriptor ed,
E instance,
Collection<String> fields)
generates a condition string for SQL statements |
|
String |
genCondition(EntityDescriptor ed,
Map<String,Object> args)
generates a condition string for SQL statements |
|
String |
genDBCreation(DatabaseModel dbInfo)
generates a SQL string to create a database |
|
String |
genIndexCreation(IndexDefinition ii)
generates a SQL string to create an index |
|
String |
genIndexRemoval(IndexDefinition ii)
generates a SQL string to remove an index |
|
String |
genInsert(EntityDescriptor ed,
Entity instance)
generates a SQL-insert statement for given instance |
|
String |
genInsertIdQuery(EntityDescriptor ed,
Date dtCreated,
String userName)
generates a query for the generated autoincrement key. |
|
String |
genOrder(EntityDescriptor ed,
Collection<String> properties)
generates the sorting part of a SQL query |
|
String |
genOrder(EntityDescriptor ed,
Collection<String> properties,
Collection<SortInfo> orderSequence)
generates the sorting part of an SQL-query. |
|
protected abstract String |
genPrimary(TableDefinition ti)
|
|
String |
genRemove(EntityDescriptor ed,
Collection<ConditionElement> args)
generates a SQL delete statement |
|
String |
genSchemaAccess(SchemaDefinition schemInfo,
String defaultUser)
generates a SQL-string to grant access rights to schema |
|
String |
genSchemaCreation(SchemaDefinition schemInfo)
generates a SQL string to create a schema |
|
String |
genSequenceReset(TableDefinition tbInfo)
generates a SQL string to reset an external sequence |
|
String |
genTableCreation(TableDefinition tbInfo)
generates a SQL string to create a database table |
|
String |
genTableMetaAccess(TableDefinition tbInfo)
generates a SQL query that returns no data to access tables meta data information |
|
String |
genTablePKCreation(TableDefinition tbInfo)
generates a statement to create an external sequence for autoincrement-column |
|
String |
genTablePKMod(TableDefinition tbInfo)
generates a statement to modify the external sequence after table creation. |
|
String |
genTableRemoval(TableDefinition tbInfo)
generates a SQL string that removes a table from database |
|
String |
genTableRemoval(TableDefinition tbInfo,
boolean withExist)
generates a SQL string that removes a table from database. |
|
String |
genTruncate(EntityDescriptor ed)
generates a SQL statement that truncates a database table, which means, that all entries will be removed. |
|
String |
genUpdate(EntityDescriptor ed,
Entity instance)
generates a SQL statement to change the persistent view of an entity |
|
String |
genUpdate(EntityDescriptor ed,
Entity instance,
Collection<String> fields,
boolean withCondition)
generates a SQL statement to partially change the persistent view of an entity. |
|
String |
genUserCreation(String user,
String password)
generates a SQL statement to create a user/role/principal |
|
protected abstract String |
getDBCharset()
|
|
protected abstract String |
getIndexName(IndexDefinition ii)
|
|
protected org.apache.commons.logging.Log |
getLogger()
|
|
String |
getMapped(EntityDescriptor ed,
String attributeName)
get the physical name for the given property, already quoted with the right syntax for the involved database |
|
protected abstract String |
getTableAttributes(TableDefinition tbInfo)
|
|
protected String |
getTypeFor(ColumnDefinition ci)
|
|
ColumnType |
getTypeFrom(int sqlType)
maps SQL types to logical ColumnType s used by application |
|
protected abstract String |
getUsernameFor(String user,
String host)
|
|
Collection<IndexMetaData> |
indexDefinitions(Connection conn,
TableDefinition td)
|
|
protected abstract boolean |
isExistsSupported()
signals whether current database supports exists on drop tables |
|
boolean |
needsUpdate(ColumnDefinition master,
ColumnDefinition other)
|
|
boolean |
needsUpdate(IndexDefinition master,
IndexDefinition other)
|
|
Collection<SchemaDefinition> |
schemaDefinitions(Connection conn)
|
|
protected abstract boolean |
supportsNativeSchemata()
|
|
Collection<TableDefinition> |
tableDefinitions(Connection conn,
SchemaDefinition sd)
|
|
protected String |
xpandInsert(EntityDescriptor ed)
some databases need special keywords on insert statements to return the values of autoincrement keys. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface de.schwarzrot.data.access.support.DbUtil |
---|
genAccessRightsFor, genDBAccess, genUserCreation, getFieldSeparator, getMapped, getSchemaSeparator, getTableNameFor, getTableNameFor, getTerminator, needDropIndexAfterDropTable, needExternalSequenceForSerial, needSequenceResetAfterTruncate, quoteAndCutValue, supportsGeneratedKeyQuery |
Field Detail |
---|
protected static final Map<String,Integer> skipList
Constructor Detail |
---|
public AbstractDbUtils()
Method Detail |
---|
public Collection<ColumnMetaData> columnDefinitions(Connection conn, TableDefinition td)
columnDefinitions
in interface DbUtil
public String genAccessRightsForPK(TableDefinition tbInfo, String defaultUser)
DbUtil
genAccessRightsForPK
in interface DbUtil
tbInfo
- - table model informationdefaultUser
- - the user that gets the rights granted
public String genColumnCreation(ColumnDefinition cd)
DbUtil
genColumnCreation
in interface DbUtil
cd
- - column model information
public String genColumnModification(ColumnDefinition cd)
DbUtil
genColumnModification
in interface DbUtil
cd
- - column model information
public String genCondition(EntityDescriptor ed, Collection<ConditionElement> args)
DbUtil
genCondition
in interface DbUtil
ed
- - descriptor of the entityargs
- - list of elements that form the condition
public <E extends Entity> String genCondition(EntityDescriptor ed, E instance, Collection<String> fields)
DbUtil
genCondition
in interface DbUtil
E
- - the entity to useed
- - descriptor of the entityinstance
- - instance of that entity, containing the values for the
conditionfields
- - list of attributes used in the condition
public String genCondition(EntityDescriptor ed, Map<String,Object> args)
DbUtil
genCondition
in interface DbUtil
ed
- - descriptor of the entityargs
- - map of attribute/value pairs to build the condition from
public String genDBCreation(DatabaseModel dbInfo)
DbUtil
genDBCreation
in interface DbUtil
dbInfo
- - database model information
public String genIndexCreation(IndexDefinition ii)
DbUtil
genIndexCreation
in interface DbUtil
ii
- - index model information
public String genIndexRemoval(IndexDefinition ii)
DbUtil
genIndexRemoval
in interface DbUtil
ii
- - index model information
public String genInsert(EntityDescriptor ed, Entity instance)
DbUtil
genInsert
in interface DbUtil
ed
- - descriptor of the entityinstance
- - the instance that should be copied to persistence
public String genInsertIdQuery(EntityDescriptor ed, Date dtCreated, String userName)
DbUtil
Statement.getGeneratedKeys()
. So they have to support at least
dirty reads.
genInsertIdQuery
in interface DbUtil
ed
- - descriptor of the entitydtCreated
- - timestamp of the insertuserName
- - name of the user that triggered the insert
public String genOrder(EntityDescriptor ed, Collection<String> properties)
DbUtil
genOrder
in interface DbUtil
ed
- - descriptor of the entityproperties
- - list of attributes to sort by
public String genOrder(EntityDescriptor ed, Collection<String> properties, Collection<SortInfo> orderSequence)
DbUtil
genOrder
in interface DbUtil
ed
- - descriptor of the entityproperties
- - list of attributes to readorderSequence
- - list of sorting segment info
public String genRemove(EntityDescriptor ed, Collection<ConditionElement> args)
DbUtil
genRemove
in interface DbUtil
ed
- - descriptor of the entity to removeargs
- - list of elements that form the condition
public String genSchemaAccess(SchemaDefinition schemInfo, String defaultUser)
DbUtil
genSchemaAccess
in interface DbUtil
schemInfo
- - schema model informationdefaultUser
- - the user that gets the rights granted
public String genSchemaCreation(SchemaDefinition schemInfo)
DbUtil
genSchemaCreation
in interface DbUtil
schemInfo
- - schema model information
public String genSequenceReset(TableDefinition tbInfo)
DbUtil
genSequenceReset
in interface DbUtil
tbInfo
- - table model information
public String genTableCreation(TableDefinition tbInfo)
DbUtil
genTableCreation
in interface DbUtil
tbInfo
- - table model information
public String genTableMetaAccess(TableDefinition tbInfo)
DbUtil
genTableMetaAccess
in interface DbUtil
tbInfo
- - table model information
public String genTablePKCreation(TableDefinition tbInfo)
DbUtil
genTablePKCreation
in interface DbUtil
tbInfo
- - table model information
public String genTablePKMod(TableDefinition tbInfo)
DbUtil
genTablePKMod
in interface DbUtil
tbInfo
- - table model information
public String genTableRemoval(TableDefinition tbInfo)
DbUtil
genTableRemoval
in interface DbUtil
tbInfo
- - table model information
public String genTableRemoval(TableDefinition tbInfo, boolean withExist)
DbUtil
genTableRemoval
in interface DbUtil
tbInfo
- - table model informationwithExist
- - flag to indicate, whether existence check should be added
public String genTruncate(EntityDescriptor ed)
DbUtil
Truncation of a table may require additional permissions beside the permission to delete records.
genTruncate
in interface DbUtil
ed
- - descriptor of the Entity
public String genUpdate(EntityDescriptor ed, Entity instance)
DbUtil
genUpdate
in interface DbUtil
ed
- - descriptor of the involved entityinstance
- - the instance to save
public String genUpdate(EntityDescriptor ed, Entity instance, Collection<String> fields, boolean withCondition)
DbUtil
genUpdate
in interface DbUtil
ed
- - descriptor of the involved entityinstance
- - instance containing the modified values to savefields
- the attribute names to modifywithCondition
- public String genUserCreation(String user, String password)
DbUtil
genUserCreation
in interface DbUtil
user
- - name of the userpassword
- - password for that user
public String getMapped(EntityDescriptor ed, String attributeName)
DbUtil
getMapped
in interface DbUtil
ed
- - descriptor of the involved entityattributeName
- - name of attribute to map
public ColumnType getTypeFrom(int sqlType)
DbUtil
ColumnType
s used by application
getTypeFrom
in interface DbUtil
sqlType
- - a SQL type to map
ColumnType
public Collection<IndexMetaData> indexDefinitions(Connection conn, TableDefinition td)
indexDefinitions
in interface DbUtil
public boolean needsUpdate(ColumnDefinition master, ColumnDefinition other)
needsUpdate
in interface DbUtil
public boolean needsUpdate(IndexDefinition master, IndexDefinition other)
needsUpdate
in interface DbUtil
public Collection<SchemaDefinition> schemaDefinitions(Connection conn)
schemaDefinitions
in interface DbUtil
public Collection<TableDefinition> tableDefinitions(Connection conn, SchemaDefinition sd)
tableDefinitions
in interface DbUtil
protected String createColumnDef(ColumnDefinition col)
protected void dumpRS(ResultSet rs)
protected abstract String genAutoIncrement(ColumnDefinition cd)
protected abstract String genPrimary(TableDefinition ti)
protected abstract String getDBCharset()
protected abstract String getIndexName(IndexDefinition ii)
protected final org.apache.commons.logging.Log getLogger()
protected abstract String getTableAttributes(TableDefinition tbInfo)
protected String getTypeFor(ColumnDefinition ci)
protected abstract String getUsernameFor(String user, String host)
protected abstract boolean isExistsSupported()
protected abstract boolean supportsNativeSchemata()
protected String xpandInsert(EntityDescriptor ed)
|
SRJRCFrames v0.1.296 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |