org.ujorm.orm.metaModel
Class MetaDbService

java.lang.Object
  extended by org.ujorm.orm.metaModel.MetaDbService
Direct Known Subclasses:
MetaDbServiceEx

public class MetaDbService
extends Object

A service method for the MetaDatabase class. The service class can be overriten

See Also:
MetaParams.META_DB_SERVICE

Field Summary
protected  boolean anyChange
          There is a database change
protected  MetaDatabase db
          Meta Database from constructor
protected  StringBuilder sql
          SQL Buffer
protected  Statement stat
          DB Statement for common use
 
Constructor Summary
MetaDbService()
           
 
Method Summary
protected  void changeIndex(List<MetaIndex> indexes)
          5.
protected  void checkKeyWord(String word, MetaTable table, Set<String> keywords)
          Check the keyword
protected  void checkReportKeywords(Connection conn, List<MetaTable> tables, List<MetaColumn> newColumns, List<MetaIndex> indexes)
          1.
 void create(MetaDatabase metaDatabase, Session session)
          Create DB
protected  void createForeignKey(List<MetaColumn> foreignColumns)
          6.
protected  void createNewColumn(List<MetaColumn> newColumns, List<MetaColumn> foreignColumns)
          4.
protected  void createSchema(int tableTotalCount, List<MetaTable> tables, Connection conn)
          2.
protected  void createSequenceTable(boolean createSequenceTable)
          7.
protected  void createTable(List<MetaTable> tables, List<MetaColumn> foreignColumns)
          3.
protected  void createTableComments(List<MetaTable> tables)
          8.
protected  void createTableComments(List<MetaTable> cTables, StringBuilder out)
          Create table and column comments.
protected  String dbIdentifier(String name, DatabaseMetaData dmd)
          Returns a native database identifirer.
protected  void executeUpdate(Appendable sql, MetaTable table)
          Check missing database table, index, or column
protected  UjoSequencer findFirstSequencer()
          Find the first sequence of the database or returns null if no sequence was not found.
protected  SqlDialect getDialect()
           
protected  SqlDialectEx getDialectEx()
          Returns an extended dialect
 StringBuilder getSql()
          SQL Buffer
protected  boolean initialize(Connection conn)
          0.
protected  boolean isAnyChange()
          Has the database any change?
protected  boolean isCatalog()
          Does the database support a catalog? The feature supports: MySqlDialect and MSSqlDialect.
protected  boolean isModelChanged(Connection conn, List<MetaTable> newTables, List<MetaColumn> newColumns, List<MetaIndex> newIndexes)
          Find database table or columns to modify.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

db

protected MetaDatabase db
Meta Database from constructor


sql

protected final StringBuilder sql
SQL Buffer


stat

protected Statement stat
DB Statement for common use


anyChange

protected boolean anyChange
There is a database change

Constructor Detail

MetaDbService

public MetaDbService()
Method Detail

create

public void create(MetaDatabase metaDatabase,
                   Session session)
Create DB


getSql

public StringBuilder getSql()
SQL Buffer


isModelChanged

protected boolean isModelChanged(Connection conn,
                                 List<MetaTable> newTables,
                                 List<MetaColumn> newColumns,
                                 List<MetaIndex> newIndexes)
                          throws SQLException
Find database table or columns to modify.

Parameters:
conn - Database connection
newTables - Output parameter
newColumns - Output parameter
Throws:
SQLException

dbIdentifier

protected String dbIdentifier(String name,
                              DatabaseMetaData dmd)
                       throws SQLException
Returns a native database identifirer.

Throws:
SQLException

initialize

protected boolean initialize(Connection conn)
                      throws Exception
0. Initialization

Throws:
Exception

checkReportKeywords

protected void checkReportKeywords(Connection conn,
                                   List<MetaTable> tables,
                                   List<MetaColumn> newColumns,
                                   List<MetaIndex> indexes)
                            throws Exception
1. CheckReport keywords:

Throws:
Exception

createSchema

protected void createSchema(int tableTotalCount,
                            List<MetaTable> tables,
                            Connection conn)
                     throws SQLException,
                            IOException
2. Create schemas:

Throws:
SQLException
IOException

createTable

protected void createTable(List<MetaTable> tables,
                           List<MetaColumn> foreignColumns)
                    throws Exception
3. Create tables:

Throws:
Exception

createNewColumn

protected void createNewColumn(List<MetaColumn> newColumns,
                               List<MetaColumn> foreignColumns)
                        throws Exception
4. Create new columns:

Throws:
Exception

changeIndex

protected void changeIndex(List<MetaIndex> indexes)
                    throws Exception
5. Create Indexes:

Throws:
Exception

createForeignKey

protected void createForeignKey(List<MetaColumn> foreignColumns)
                         throws Exception
6. Create Foreign Keys:

Throws:
Exception

createSequenceTable

protected void createSequenceTable(boolean createSequenceTable)
                            throws Exception
7. Create SEQUENCE table:

Throws:
Exception

createTableComments

protected void createTableComments(List<MetaTable> tables)
                            throws Exception
8. Create table comment for the all tables:

Throws:
Exception

createTableComments

protected void createTableComments(List<MetaTable> cTables,
                                   StringBuilder out)
Create table and column comments. An error in this method does not affect the rest of all transaction.


checkKeyWord

protected void checkKeyWord(String word,
                            MetaTable table,
                            Set<String> keywords)
                     throws Exception
Check the keyword

Throws:
Exception

executeUpdate

protected void executeUpdate(Appendable sql,
                             MetaTable table)
                      throws IllegalStateException,
                             SQLException
Check missing database table, index, or column

Throws:
IllegalStateException
SQLException

findFirstSequencer

protected UjoSequencer findFirstSequencer()
Find the first sequence of the database or returns null if no sequence was not found.


isAnyChange

protected boolean isAnyChange()
Has the database any change?


getDialect

protected SqlDialect getDialect()

getDialectEx

protected SqlDialectEx getDialectEx()
Returns an extended dialect


isCatalog

protected final boolean isCatalog()
Does the database support a catalog? The feature supports: MySqlDialect and MSSqlDialect.

Returns:
Result value is provided from a SqlDialog class.


Copyright 2013, Pavel Ponec