|
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 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 DbUtil
columnDefinitions
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 DbUtil
genAccessRightsForPK
in class AbstractDbUtils
ti
- - table model informationdefaultUser
- - the user that gets the rights granted
public String genColumnModification(ColumnDefinition cd)
DbUtil
genColumnModification
in interface DbUtil
genColumnModification
in class AbstractDbUtils
cd
- - 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 DbUtil
genSchemaAccess
in class AbstractDbUtils
schemInfo
- - schema model informationdefaultUser
- - the user that gets the rights granted
public String genSchemaCreation(SchemaDefinition schemInfo)
DbUtil
genSchemaCreation
in interface DbUtil
genSchemaCreation
in class AbstractDbUtils
schemInfo
- - schema model information
public String genTablePKCreation(TableDefinition tbInfo)
DbUtil
genTablePKCreation
in interface DbUtil
genTablePKCreation
in class AbstractDbUtils
tbInfo
- - table model information
public String genTablePKMod(TableDefinition tbInfo)
DbUtil
genTablePKMod
in interface DbUtil
genTablePKMod
in class AbstractDbUtils
tbInfo
- - table model information
public String genTruncate(EntityDescriptor ed)
DbUtil
Truncation of a table may require additional permissions beside the permission to delete records.
genTruncate
in interface DbUtil
genTruncate
in class AbstractDbUtils
ed
- - 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 DbUtil
indexDefinitions
in class AbstractDbUtils
public boolean isExistsSupported()
AbstractDbUtils
isExistsSupported
in class AbstractDbUtils
public 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 DbUtil
schemaDefinitions
in class AbstractDbUtils
public final void setOwner(String user)
public boolean supportsGeneratedKeyQuery()
DbUtil
public List<TableDefinition> tableDefinitions(Connection conn, SchemaDefinition sd)
tableDefinitions
in interface DbUtil
tableDefinitions
in class AbstractDbUtils
protected String genAutoIncrement(ColumnDefinition cd)
genAutoIncrement
in class AbstractDbUtils
protected String genPrimary(TableDefinition ti)
genPrimary
in class AbstractDbUtils
protected String getDBCharset()
getDBCharset
in class AbstractDbUtils
protected String getIndexName(IndexDefinition ii)
getIndexName
in class AbstractDbUtils
protected final String getOwner()
protected String getTableAttributes(TableDefinition td)
getTableAttributes
in class AbstractDbUtils
protected String getTypeFor(ColumnDefinition ci)
getTypeFor
in class AbstractDbUtils
protected ColumnType getTypeFrom(String rawType)
protected String getUsernameFor(String user, String host)
getUsernameFor
in class AbstractDbUtils
protected Long ownerID(Connection conn)
protected final boolean supportsNativeSchemata()
supportsNativeSchemata
in class AbstractDbUtils
protected 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 |