|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.ujorm.orm.SqlDialect
public abstract class SqlDialect
SQL dialect abstract class. Methods of this class print a SQL statement(s) along a metamodel usually. You may create a subclass of any implementation to create another SQL statement, however just I can't exclude some small changes of this API in the next release.
| Field Summary | |
|---|---|
static String |
COMMON_SEQ_TABLE_KEY
The table key for a common sequence emulator. |
static String |
DEFAULT_SCHEMA_SYMBOL
The default schema symbol |
protected OrmHandler |
ormHandler
The ORM handler |
| Constructor Summary | |
|---|---|
SqlDialect()
|
|
| Method Summary | |
|---|---|
Connection |
createConnection(MetaDatabase db)
Create a new database connection |
InitialContext |
createJndiInitialContext(MetaDatabase db)
Get or create an Initial Context for the JNDI lookup. |
protected Query |
createSubQuery(CriterionDecoder decoder)
Create a subquery for the DELETE/UPDATE statement |
protected void |
escape(CharSequence text,
Appendable out)
Escape the special character: "'" |
protected String |
getAliasColumnName(ColumnWrapper column)
Returns quoted column name including the alias table |
protected String |
getColumnType(MetaColumn column)
Returns a database column type |
String |
getCriterionTemplate(ValueCriterion crit)
Returns an SQL criterion template. |
SqlDialectEx |
getExtentedDialect()
Get an Extended dialect |
abstract String |
getJdbcDriver()
Returns a JDBC driver class name. |
abstract String |
getJdbcUrl()
Returns a default JDBC URL |
Set<String> |
getKeywordSet(Connection conn)
Return database SQL keyword set in the upper case. |
SqlNameProvider |
getNameProvider()
Returns a name provider |
protected String |
getQuotedName(CharSequence name)
Prints quoted name (identifier) to SQL - always. |
SeqTableModel |
getSeqTableModel()
The table model for an internal sequence table support |
boolean |
isCatalog()
Does the database support a catalog? The feature supports: MySqlDialect and MSSqlDialect. |
protected boolean |
isColumnLengthAllowed(MetaColumn column)
Is allowed a column length in a SQL phrase for creating column? The length example can be: NAME CHAR(10) |
protected boolean |
isFilled(CharSequence text)
Returns true, if the argument text is not null and not empty. |
boolean |
isMultiRowInsertSupported()
Is supported the Multirow inserts ? Default value is true |
Appendable |
printAlterTableAddColumn(MetaColumn column,
Appendable out)
Print a SQL script to add a new column to the table |
Appendable |
printAlterTableColumn(MetaColumn column,
boolean add,
Appendable out)
Print a SQL script to add a new column to the table |
Appendable |
printCall(MetaProcedure procedure,
Appendable out)
Print the call of a stored procedure by template: {? = call procedure_when(?,?)} |
Appendable |
printColumnAlias(ColumnWrapper column,
Appendable out)
Print a full SQL column alias name by sample: "TABLE_ALIAS"."ORIG_COLUMN" |
Appendable |
printColumnDeclaration(MetaColumn column,
String aName,
Appendable out)
Print a SQL to create column |
Appendable |
printComment(MetaColumn column,
Appendable out)
Print a Comment to a database Column |
Appendable |
printComment(MetaTable table,
Appendable out)
Print a Comment to a database Table |
Appendable |
printCommit(Appendable out)
Print SQL 'COMMIT' |
Appendable |
printCreateSchema(String schema,
Appendable out)
Print SQL 'CREATE SCHEMA' |
ValueCriterion |
printCriterion(ValueCriterion crit,
Appendable out)
Print a condition phrase from the criterion. |
protected ValueCriterion |
printCriterionValue(String template,
ColumnWrapper column,
ValueCriterion crit,
Appendable out)
Write a right value form criterion |
Appendable |
printDefaultConstraint(MetaColumn column,
StringBuilder out)
Print Default Constraint |
Appendable |
printDefaultSchema(String schema,
Appendable out)
Deprecated. |
Appendable |
printDefaultValue(MetaColumn column,
Appendable out)
Print a SQL phrase for the DEFAULT VALUE, for example: DEFAULT 777 |
Appendable |
printDelete(CriterionDecoder decoder,
Appendable out)
Print an SQL DELETE statement. |
Appendable |
printFKColumnsDeclaration(MetaColumn column,
Appendable out)
Print a SQL to create foreign keys. |
Appendable |
printForeignKey(MetaColumn column,
Appendable out)
Print foreign key for the parameter column |
void |
printForeignKey(ValueCriterion crit,
ColumnWrapper column,
String template,
Appendable out)
Print all items of the foreign key |
Appendable |
printFullTableName(MetaTable table,
Appendable out)
Print a full SQL table name by sample: SCHEMA.TABLE |
Appendable |
printFullTableName(MetaTable table,
boolean printSymbolSchema,
Appendable out)
Print a extended SQL table name by sample: SCHEMA.TABLE |
Appendable |
printIndex(MetaIndex index,
Appendable out)
Print an INDEX for the parameter column. |
Appendable |
printInsert(List<? extends OrmUjo> bos,
int idxFrom,
int idxTo,
Appendable out)
Print an SQL INSERT statement. |
Appendable |
printInsert(OrmUjo bo,
Appendable out)
Print an SQL INSERT statement. |
Appendable |
printInsertBySelect(List<? extends OrmUjo> bos,
int idxFrom,
int idxTo,
String fromPhrase,
Appendable out)
Print an batch SQL INSERT statement using SELECT UNION statement. |
void |
println(Appendable out)
Print the new line. |
protected Appendable |
printLockForSelect(Query query,
Appendable out)
Print a 'lock clausule' to the end of SQL SELECT statement to use a pessimistic lock. |
Appendable |
printNextSequence(String sequenceName,
MetaTable table,
Appendable out)
Create a SQL script for the NEXT SEQUENCE from a native database sequencer |
void |
printOffset(Query query,
Appendable out)
Print an OFFSET of the statement SELECT. |
Appendable |
printQuotedName(CharSequence name,
Appendable sql)
Prints quoted name (identifier) to SQL according the parameter MetaParams.QUOTE_SQL_NAMES. |
protected Appendable |
printQuotedNameAlways(CharSequence name,
Appendable sql)
Prints quoted name (identifier) to SQL always. |
Appendable |
printSelect(TableWrapper table,
Query query,
boolean count,
Appendable out)
Print a SQL SELECT by table model and query |
protected void |
printSelectOrder(Query query,
Appendable out)
Print SQL ORDER BY |
protected Appendable |
printSelectTable(Query query,
boolean count,
Appendable out)
Print SQL database SELECT |
protected void |
printSelectTableBase(Query query,
boolean count,
Appendable out)
Print SQL database SELECT |
protected Appendable |
printSelectView(TableWrapper table,
Query query,
boolean count,
Appendable out)
Print SQL view SELECT |
Appendable |
printSequenceCurrentValue(UjoSequencer sequence,
Appendable out)
Print SQL CURRENT SEQUENCE VALUE. |
Appendable |
printSequenceDeleteById(UjoSequencer sequence,
String id,
Appendable out)
Print SQL DELETE SEQUENCE BY ID. |
Appendable |
printSequenceInit(UjoSequencer sequence,
Appendable out)
Print SQL CREATE SEQUENCE (insert sequence row). |
Appendable |
printSequenceInitWithValues(UjoSequencer sequence,
long seq,
int cache,
Appendable out)
|
Appendable |
printSequenceNextValue(UjoSequencer sequence,
Appendable out)
Print SQL UPDATE NEXT SEQUENCE value. |
Appendable |
printSequenceTable(MetaDatabase db,
Appendable out)
Print SQL CREATE SEQUENCE. |
protected Appendable |
printSequenceTableName(UjoSequencer sequence,
Appendable out)
Prinnt the full sequence table |
Appendable |
printSetMaxSequence(UjoSequencer sequence,
Appendable out)
Set sequence to the max value. |
Appendable |
printTable(MetaTable table,
Appendable out)
Print a SQL script to create table |
void |
printTableAliasDefinition(TableWrapper table,
Appendable out)
Print a SQL database and table name and an alias definition - by sample: SCHEMA.TABLE ALIAS |
void |
printTableColumns(Collection<? extends ColumnWrapper> columns,
Appendable values,
Appendable out)
Print table columns |
Appendable |
printUpdate(List<MetaColumn> changedColumns,
CriterionDecoder decoder,
Appendable out)
Print an SQL UPDATE statement. |
void |
releaseSavepoint(Connection conn,
Savepoint savepoint,
boolean afterRollback)
Perform the method: {@link Connection#releaseSavepoint(java.sql.Savepoint) ? |
void |
setHandler(OrmHandler ormHandler)
Set the OrmHandler - the method is for internal call only. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String COMMON_SEQ_TABLE_KEY
public static final String DEFAULT_SCHEMA_SYMBOL
protected OrmHandler ormHandler
| Constructor Detail |
|---|
public SqlDialect()
| Method Detail |
|---|
public void setHandler(OrmHandler ormHandler)
public abstract String getJdbcUrl()
public abstract String getJdbcDriver()
public Connection createConnection(MetaDatabase db)
throws Exception
Exception
public InitialContext createJndiInitialContext(MetaDatabase db)
throws NamingException
NamingExceptionpublic boolean isCatalog()
false.
public Appendable printCreateSchema(String schema,
Appendable out)
throws IOException
IOException
@Deprecated
public Appendable printDefaultSchema(String schema,
Appendable out)
throws IOException
IOException
public final Appendable printFullTableName(MetaTable table,
Appendable out)
throws IOException
IOException
public Appendable printFullTableName(MetaTable table,
boolean printSymbolSchema,
Appendable out)
throws IOException
printSymbolSchema - True parameter replaces a IOException
public void printTableAliasDefinition(TableWrapper table,
Appendable out)
throws IOException
IOException
public Appendable printColumnAlias(ColumnWrapper column,
Appendable out)
throws IOException
IOException
public Appendable printTable(MetaTable table,
Appendable out)
throws IOException
IOException
public Appendable printAlterTableAddColumn(MetaColumn column,
Appendable out)
throws IOException
IOException
public Appendable printAlterTableColumn(MetaColumn column,
boolean add,
Appendable out)
throws IOException
IOException
public Appendable printDefaultValue(MetaColumn column,
Appendable out)
throws IOException
IOException
public Appendable printDefaultConstraint(MetaColumn column,
StringBuilder out)
throws IOException
IOException
public Appendable printForeignKey(MetaColumn column,
Appendable out)
throws IOException
IOException
public Appendable printIndex(MetaIndex index,
Appendable out)
throws IOException
IOExceptionprotected boolean isColumnLengthAllowed(MetaColumn column)
public Appendable printColumnDeclaration(MetaColumn column,
String aName,
Appendable out)
throws IOException
column - Database ColumnaName - The name parameter is not mandatory, the not null value means a foreign key.
IOExceptionprotected String getColumnType(MetaColumn column)
public Appendable printFKColumnsDeclaration(MetaColumn column,
Appendable out)
throws IOException
IOException
public Appendable printInsert(OrmUjo bo,
Appendable out)
throws IOException
IOException
public Appendable printInsert(List<? extends OrmUjo> bos,
int idxFrom,
int idxTo,
Appendable out)
throws IOException
bos - Business object listidxFrom - Start index from listidxTo - Finished index from list (excluded)
IOExceptionisMultiRowInsertSupported()
public Appendable printInsertBySelect(List<? extends OrmUjo> bos,
int idxFrom,
int idxTo,
String fromPhrase,
Appendable out)
throws IOException
bos - Business object listidxFrom - Start index from listidxTo - Finished index from list (excluded)fromPhrase - For example the Oracle syntax: SELECT 1,2,3 FROM DUAL;
IOExceptionisMultiRowInsertSupported()public boolean isMultiRowInsertSupported()
Multi row insert
public Appendable printUpdate(List<MetaColumn> changedColumns,
CriterionDecoder decoder,
Appendable out)
throws IOException
IOException
public Appendable printDelete(CriterionDecoder decoder,
Appendable out)
throws IOException
IOExceptionprotected Query createSubQuery(CriterionDecoder decoder)
public String getCriterionTemplate(ValueCriterion crit)
switch (crit.getOperator()) {
case EQ:
return "{0}={1}";
case NOT_EQ:
return "{0}<>{1}";
case GT:
return "{0}>{1}";
...
public void printTableColumns(Collection<? extends ColumnWrapper> columns,
Appendable values,
Appendable out)
throws IOException
columns - List of tablel columnsvalues - Print columns including its aliases.out - Table columns output.
IOException
public ValueCriterion printCriterion(ValueCriterion crit,
Appendable out)
throws IOException
IOException
protected ValueCriterion printCriterionValue(String template,
ColumnWrapper column,
ValueCriterion crit,
Appendable out)
throws IOException
IOException
protected String getAliasColumnName(ColumnWrapper column)
throws IOException
IOException
public void printForeignKey(ValueCriterion crit,
ColumnWrapper column,
String template,
Appendable out)
throws IOException
IOException
public final Appendable printSelect(TableWrapper table,
Query query,
boolean count,
Appendable out)
throws IOException
query - The UJO querycount - only count of items is required;
IOException
protected Appendable printSelectView(TableWrapper table,
Query query,
boolean count,
Appendable out)
throws IOException
query - The UJO querycount - only count of items is required;
IOException
protected Appendable printSelectTable(Query query,
boolean count,
Appendable out)
throws IOException
query - The UJO querycount - only count of items is required;
IOException
protected void printSelectTableBase(Query query,
boolean count,
Appendable out)
throws IOException
query - The UJO querycount - only count of items is required;
IOException
protected Appendable printLockForSelect(Query query,
Appendable out)
throws IOException,
UnsupportedOperationException
query - The UJO query
IOException
UnsupportedOperationException
protected void printSelectOrder(Query query,
Appendable out)
throws IOException
IOException
public Appendable printCall(MetaProcedure procedure,
Appendable out)
throws IOException
IOException
public void printOffset(Query query,
Appendable out)
throws IOException
IOException
protected Appendable printSequenceTableName(UjoSequencer sequence,
Appendable out)
throws IOException
IOException
public Appendable printSequenceTable(MetaDatabase db,
Appendable out)
throws IOException
IOException
public Appendable printSequenceInit(UjoSequencer sequence,
Appendable out)
throws IOException
IOException
public Appendable printSequenceInitWithValues(UjoSequencer sequence,
long seq,
int cache,
Appendable out)
throws IOException
IOException
public Appendable printSequenceNextValue(UjoSequencer sequence,
Appendable out)
throws IOException
IOException
public Appendable printSetMaxSequence(UjoSequencer sequence,
Appendable out)
throws IOException
IOException
public Appendable printSequenceCurrentValue(UjoSequencer sequence,
Appendable out)
throws IOException
IOException
public Appendable printSequenceDeleteById(UjoSequencer sequence,
String id,
Appendable out)
throws IOException
IOExceptionprotected final boolean isFilled(CharSequence text)
public final void println(Appendable out)
throws IOException
IOException
public Appendable printCommit(Appendable out)
throws IOException
IOException
public Appendable printComment(MetaTable table,
Appendable out)
throws IOException
IOException
public Appendable printComment(MetaColumn column,
Appendable out)
throws IOException
IOExceptionpublic Set<String> getKeywordSet(Connection conn)
protected final void escape(CharSequence text,
Appendable out)
throws IOException
IOExceptionpublic SeqTableModel getSeqTableModel()
public void releaseSavepoint(Connection conn,
Savepoint savepoint,
boolean afterRollback)
throws SQLException
conn - Database Connectionsavepoint - Required SavepointafterRollback - release is called after a rollback ?
SQLExceptionhttp://technet.microsoft.com/en-us/library/ms378791%28v=sql.110%29.aspx,
Connection.releaseSavepoint(java.sql.Savepoint)
public final Appendable printQuotedName(CharSequence name,
Appendable sql)
throws IOException
MetaParams.QUOTE_SQL_NAMES.
name - Name (identifier) for quotingsql - Target SQL for printing new quoted name
IOException
protected Appendable printQuotedNameAlways(CharSequence name,
Appendable sql)
throws IOException
name - Name (identifier) for quotingsql - Target SQL for printing new quoted name
IOException
protected final String getQuotedName(CharSequence name)
throws IOException
IOException
public SqlNameProvider getNameProvider()
throws IllegalStateException
IllegalStateException - A problem during creating an instance.public SqlDialectEx getExtentedDialect()
public Appendable printNextSequence(String sequenceName,
MetaTable table,
Appendable out)
throws IOException
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||