org.ujoframework.orm.metaModel
Class MetaDatabase

java.lang.Object
  extended by org.ujoframework.extensions.AbstractUjo
      extended by org.ujoframework.implementation.quick.QuickUjo
          extended by org.ujoframework.orm.AbstractMetaModel
              extended by org.ujoframework.orm.metaModel.MetaDatabase
All Implemented Interfaces:
java.io.Serializable, UjoCloneable, UjoTextable, Ujo

public final class MetaDatabase
extends AbstractMetaModel

A logical database description.

Author:
Pavel Ponec
See Also:
Serialized Form

Field Summary
static Property<MetaDatabase,java.lang.Class> DIALECT
          SQL dialect type of Class<SqlDialect>
static Property<MetaDatabase,java.lang.String> ID
          The meta-model id
static Property<MetaDatabase,java.lang.String> JDBC_DRIVER
          JDBC Driver
static Property<MetaDatabase,java.lang.String> JDBC_URL
          JDBC URL connection
static ListProperty<MetaDatabase,java.lang.String> JNDI
          JNDI (java naming and directory interface) connection string
static Property<MetaDatabase,java.lang.String> PASSWORD
          DB password
static ListProperty<MetaDatabase,MetaProcedure> PROCEDURES
          List of procedures
static Property<MetaDatabase,OrmUjo> ROOT
          An instance of the DB class.
static Property<MetaDatabase,java.lang.Class> SEQUENCER
          The sequencer class for tables of the current database.
static Property<MetaDatabase,java.lang.String> SCHEMA
          MetaDatabase default schema
static ListProperty<MetaDatabase,MetaTable> TABLES
          List of tables
static Property<MetaDatabase,java.lang.String> USER
          DB user
 
Constructor Summary
MetaDatabase()
           
MetaDatabase(OrmHandler ormHandler, OrmUjo database, MetaDatabase param)
          Create a new Database.
 
Method Summary
static void close(java.sql.Connection connection, JdbcStatement statement, java.sql.ResultSet rs, boolean throwExcepton)
          Close a connection, statement and a result set.
static void close(java.sql.Connection connection, java.sql.Statement statement, java.sql.ResultSet rs, boolean throwExcepton)
          Close a connection, statement and a result set.
 void create(Session session)
          Create DB
 java.sql.Connection createConnection()
          Create connection with auto-commit false.
 java.sql.Connection createInternalConnection()
          Call the method from SqlDialect only.
protected  UjoSequencer createSequencer(MetaTable table)
          Create a new sequencer for selected table
 boolean equals(java.lang.Object obj)
          Equals
 Session getDefaultSession()
          Returns a default handler session.
 SqlDialect getDialect()
          Returns a SQL dialect for the current database.
 java.lang.String getId()
          Returns an ID of the MetaDatabase.
 java.util.List<MetaIndex> getIndexList()
          Returns all database indexes
 OrmHandler getOrmHandler()
          OrmHandler
 MetaParams getParams()
          Return the OrmHandler parameters
 int hashCode()
          Hash code
 void changeDbLength(MetaColumn column)
          Change DbType by a Java property
 void changeDbType(MetaColumn column)
          Change DbType by a Java property
protected  void checkKeyWord(java.lang.String word, MetaTable table, java.util.Set<java.lang.String> keywords)
          Check the keyword
 java.lang.String toString()
          A String representation.
 
Methods inherited from class org.ujoframework.orm.AbstractMetaModel
get, changeDefault, checkReadOnly, isUsable, isUsable, readAuthorization, readOnly, setReadOnly, writeValue
 
Methods inherited from class org.ujoframework.implementation.quick.QuickUjo
newListProperty, newListProperty, newProperty, newProperty, newProperty, newProperty, newProperty, newProperty, readValue
 
Methods inherited from class org.ujoframework.extensions.AbstractUjo
clone, init, init, readProperties, readUjoManager, readValueString, writeValueString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ID

public static final Property<MetaDatabase,java.lang.String> ID
The meta-model id


SCHEMA

public static final Property<MetaDatabase,java.lang.String> SCHEMA
MetaDatabase default schema


DIALECT

public static final Property<MetaDatabase,java.lang.Class> DIALECT
SQL dialect type of Class<SqlDialect>


TABLES

public static final ListProperty<MetaDatabase,MetaTable> TABLES
List of tables


PROCEDURES

public static final ListProperty<MetaDatabase,MetaProcedure> PROCEDURES
List of procedures


JDBC_URL

public static final Property<MetaDatabase,java.lang.String> JDBC_URL
JDBC URL connection


JDBC_DRIVER

public static final Property<MetaDatabase,java.lang.String> JDBC_DRIVER
JDBC Driver


USER

public static final Property<MetaDatabase,java.lang.String> USER
DB user


PASSWORD

public static final Property<MetaDatabase,java.lang.String> PASSWORD
DB password


ROOT

public static final Property<MetaDatabase,OrmUjo> ROOT
An instance of the DB class.


JNDI

public static final ListProperty<MetaDatabase,java.lang.String> JNDI
JNDI (java naming and directory interface) connection string


SEQUENCER

public static final Property<MetaDatabase,java.lang.Class> SEQUENCER
The sequencer class for tables of the current database. A value can be a subtype of 'org.ujoframework.orm.UjoSequencer' with one-parameter constructor type of MetaTable. If the NULL value is specified the then a default sequencer 'UjoSequencer' will be used.

Constructor Detail

MetaDatabase

public MetaDatabase()

MetaDatabase

public MetaDatabase(OrmHandler ormHandler,
                    OrmUjo database,
                    MetaDatabase param)
Create a new Database.

Parameters:
ormHandler - ORM handler
database - Database instance
param - Configuration data from a XML file
Method Detail

getDialect

public SqlDialect getDialect()
Returns a SQL dialect for the current database.


changeDbType

public void changeDbType(MetaColumn column)
Change DbType by a Java property


changeDbLength

public void changeDbLength(MetaColumn column)
Change DbType by a Java property


create

public void create(Session session)
Create DB


close

public static void close(java.sql.Connection connection,
                         JdbcStatement statement,
                         java.sql.ResultSet rs,
                         boolean throwExcepton)
                  throws java.lang.IllegalStateException
Close a connection, statement and a result set.

Throws:
java.lang.IllegalStateException

checkKeyWord

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

Throws:
java.lang.Exception

close

public static void close(java.sql.Connection connection,
                         java.sql.Statement statement,
                         java.sql.ResultSet rs,
                         boolean throwExcepton)
                  throws java.lang.IllegalStateException
Close a connection, statement and a result set.

Throws:
java.lang.IllegalStateException

getOrmHandler

public OrmHandler getOrmHandler()
OrmHandler


getParams

public MetaParams getParams()
Return the OrmHandler parameters


getId

public java.lang.String getId()
Returns an ID of the MetaDatabase.


createConnection

public java.sql.Connection createConnection()
                                     throws java.lang.Exception
Create connection with auto-commit false.

Throws:
java.lang.Exception

createInternalConnection

public java.sql.Connection createInternalConnection()
                                             throws java.lang.Exception
Call the method from SqlDialect only. Connection is set to autocommit to false.

Throws:
java.lang.Exception

equals

public boolean equals(java.lang.Object obj)
Equals

Overrides:
equals in class AbstractUjo

hashCode

public int hashCode()
Hash code

Overrides:
hashCode in class java.lang.Object

getDefaultSession

public Session getDefaultSession()
Returns a default handler session. It is a session of the first database.


createSequencer

protected UjoSequencer createSequencer(MetaTable table)
Create a new sequencer for selected table


getIndexList

public java.util.List<MetaIndex> getIndexList()
Returns all database indexes


toString

public java.lang.String toString()
Description copied from class: AbstractUjo
A String representation.

Overrides:
toString in class AbstractUjo


Copyright © 2010. All Rights Reserved.