| 
 | SRJRCFrames v0.1.296 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.schwarzrot.data.access.support.AbstractDbUtils
de.schwarzrot.data.access.support.PgUtils
public final class PgUtils
postgresql-variant of utility-class to handle physical dependencies to database, like quoting, schema support, ...
As postgres has very poor jdbc support, a lots of hacks have to been added, to bring this kindof database into play.
First - postgres has no metadata support, where SRJRCFrames heavily uses metadata - so we have to build the metadata from postgres system catalog.
Next - the major ugliness of postgres is the inconsistent usage of implicit statements - undocumented and for some statements impossible to use. So - for me - the only way to get postgres working, was the application user being the owner of a database. That's fucking ugly and insecure. I don't like it and so I'll never use postgres, but there may be users out there thinking different and after all, I'd like to support the way to think different.
So - my rules - to get postgres working with java applications
| Field Summary | |
|---|---|
| static String | FIELD_SEPARATOR | 
| static String | SCHEMA_SEPARATOR | 
| Fields inherited from class de.schwarzrot.data.access.support.AbstractDbUtils | 
|---|
| skipList | 
| Fields inherited from interface de.schwarzrot.data.access.support.DbUtil | 
|---|
| EMPTY_STRING, ONE_SPACE, PK_NAME | 
| Constructor Summary | |
|---|---|
| PgUtils() | |
| Method Summary | |
|---|---|
|  List<ColumnMetaData> | columnDefinitions(Connection conn,
                  TableDefinition td) | 
|  String | genAccessRightsFor(TableDefinition ti,
                   String defaultUser)generates a SQL-string to grant access rights to tables | 
|  String | genAccessRightsForPK(TableDefinition ti,
                     String defaultUser)generates a SQL-string to grant access to an external sequence | 
| protected  String | genAutoIncrement(ColumnDefinition cd) | 
|  String | genColumnModification(ColumnDefinition cd)generates a SQL string to modify a column of an existing table | 
|  String | genDBAccess(DatabaseModel dbInfo,
            String user)generates a SQL-string to grant access rights to the entire database | 
| protected  String | genPrimary(TableDefinition ti) | 
|  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 | 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 | genTruncate(EntityDescriptor ed)generates a SQL statement that truncates a database table, which means, that all entries will be removed. | 
|  String | genUserCreation(String user,
                String password,
                String host)generates a SQL statement to create a user/role/principal. | 
| protected  String | getDBCharset() | 
|  String | getFieldSeparator()returns the separator used in field lists | 
| protected  String | getIndexName(IndexDefinition ii) | 
|  String | getMapped(String dbObjName)returns the quoted name of database identifiers (table, column, etc), cause we always want do handle case sensitive identifiers | 
| protected  String | getOwner() | 
|  String | getSchemaSeparator()returns the schema separator for the actual storage. | 
| protected  String | getTableAttributes(TableDefinition td) | 
|  String | getTableNameFor(EntityDescriptor ed)returns the tablename for given entity | 
|  String | getTableNameFor(TableDefinition ti)returns the tablename of given table model information | 
|  String | getTerminator()returns the terminator of SQL statements | 
| protected  String | getTypeFor(ColumnDefinition ci) | 
| protected  ColumnType | getTypeFrom(String rawType) | 
| protected  String | getUsernameFor(String user,
               String host) | 
|  List<IndexMetaData> | indexDefinitions(Connection conn,
                 TableDefinition td) | 
|  boolean | isExistsSupported()signals whether current database supports exists on drop tables | 
|  boolean | needDropIndexAfterDropTable()signals whether an index must be dropped separately after removal of a table | 
|  boolean | needExternalSequenceForSerial()signals whether the database needs an external sequence to support autoincrement columns | 
|  boolean | needSequenceResetAfterTruncate()signals whether the database needs to set a new value to the sequence on removing all records of a table | 
| protected  Long | ownerID(Connection conn) | 
|  String | quoteAndCutValue(Object value,
                 int size)some databases pad strings to an unsupported size, so this call ensures, that the quoted string does not exceed the defined column size. | 
|  List<SchemaDefinition> | schemaDefinitions(Connection conn) | 
|  void | setOwner(String user) | 
|  boolean | supportsGeneratedKeyQuery()signals whether the JDBC implementation supports the call for generated (autoincrement) keys. | 
| protected  boolean | supportsNativeSchemata() | 
|  List<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 de.schwarzrot.data.access.support.AbstractDbUtils | 
|---|
| createColumnDef, dumpRS, genColumnCreation, genCondition, genCondition, genCondition, genDBCreation, genIndexCreation, genIndexRemoval, genInsert, genInsertIdQuery, genOrder, genOrder, genRemove, genSequenceReset, genTableCreation, genTableMetaAccess, genTableRemoval, genTableRemoval, genUpdate, genUpdate, genUserCreation, getLogger, getMapped, getTypeFrom, needsUpdate, needsUpdate | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
public static final String FIELD_SEPARATOR
public static final String SCHEMA_SEPARATOR
| Constructor Detail | 
|---|
public PgUtils()
| Method Detail | 
|---|
public List<ColumnMetaData> columnDefinitions(Connection conn,
                                              TableDefinition td)
columnDefinitions in interface DbUtilcolumnDefinitions in class AbstractDbUtils
public String genAccessRightsFor(TableDefinition ti,
                                 String defaultUser)
DbUtil
ti - - table model informationdefaultUser - - the user that gets the rights granted
public String genAccessRightsForPK(TableDefinition ti,
                                   String defaultUser)
DbUtil
genAccessRightsForPK in interface DbUtilgenAccessRightsForPK in class AbstractDbUtilsti - - table model informationdefaultUser - - the user that gets the rights granted
public String genColumnModification(ColumnDefinition cd)
DbUtil
genColumnModification in interface DbUtilgenColumnModification in class AbstractDbUtilscd - - column model information
public String genDBAccess(DatabaseModel dbInfo,
                          String user)
DbUtil
dbInfo - - database model informationuser - - the user that gets the rights granted
public String genSchemaAccess(SchemaDefinition schemInfo,
                              String defaultUser)
DbUtil
genSchemaAccess in interface DbUtilgenSchemaAccess in class AbstractDbUtilsschemInfo - - schema model informationdefaultUser - - the user that gets the rights granted
public String genSchemaCreation(SchemaDefinition schemInfo)
DbUtil
genSchemaCreation in interface DbUtilgenSchemaCreation in class AbstractDbUtilsschemInfo - - schema model information
public String genTablePKCreation(TableDefinition tbInfo)
DbUtil
genTablePKCreation in interface DbUtilgenTablePKCreation in class AbstractDbUtilstbInfo - - table model information
public String genTablePKMod(TableDefinition tbInfo)
DbUtil
genTablePKMod in interface DbUtilgenTablePKMod in class AbstractDbUtilstbInfo - - table model information
public String genTruncate(EntityDescriptor ed)
DbUtilTruncation of a table may require additional permissions beside the permission to delete records.
genTruncate in interface DbUtilgenTruncate in class AbstractDbUtilsed - - descriptor of the Entity
public String genUserCreation(String user,
                              String password,
                              String host)
DbUtil
user - - name of the userpassword - - password for that userhost - - name of the host
public String getFieldSeparator()
DbUtil
public String getMapped(String dbObjName)
DbUtil
dbObjName - - the identifier to quote
public String getSchemaSeparator()
DbUtil
public String getTableNameFor(EntityDescriptor ed)
DbUtil
ed - - descriptor of an entity
public String getTableNameFor(TableDefinition ti)
DbUtil
ti - - table model information
public String getTerminator()
DbUtil
public List<IndexMetaData> indexDefinitions(Connection conn,
                                            TableDefinition td)
indexDefinitions in interface DbUtilindexDefinitions in class AbstractDbUtilspublic boolean isExistsSupported()
AbstractDbUtils
isExistsSupported in class AbstractDbUtilspublic boolean needDropIndexAfterDropTable()
DbUtil
public boolean needExternalSequenceForSerial()
DbUtil
public boolean needSequenceResetAfterTruncate()
DbUtil
public String quoteAndCutValue(Object value,
                               int size)
DbUtil
value - - the value to storesize - - declared field size
public List<SchemaDefinition> schemaDefinitions(Connection conn)
schemaDefinitions in interface DbUtilschemaDefinitions in class AbstractDbUtilspublic final void setOwner(String user)
public boolean supportsGeneratedKeyQuery()
DbUtil
public List<TableDefinition> tableDefinitions(Connection conn,
                                              SchemaDefinition sd)
tableDefinitions in interface DbUtiltableDefinitions in class AbstractDbUtilsprotected String genAutoIncrement(ColumnDefinition cd)
genAutoIncrement in class AbstractDbUtilsprotected String genPrimary(TableDefinition ti)
genPrimary in class AbstractDbUtilsprotected String getDBCharset()
getDBCharset in class AbstractDbUtilsprotected String getIndexName(IndexDefinition ii)
getIndexName in class AbstractDbUtilsprotected final String getOwner()
protected String getTableAttributes(TableDefinition td)
getTableAttributes in class AbstractDbUtilsprotected String getTypeFor(ColumnDefinition ci)
getTypeFor in class AbstractDbUtilsprotected ColumnType getTypeFrom(String rawType)
protected String getUsernameFor(String user,
                                String host)
getUsernameFor in class AbstractDbUtilsprotected Long ownerID(Connection conn)
protected final boolean supportsNativeSchemata()
supportsNativeSchemata in class AbstractDbUtilsprotected String xpandInsert(EntityDescriptor ed)
AbstractDbUtils
xpandInsert in class AbstractDbUtils| 
 | SRJRCFrames v0.1.296 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||