org.ujorm.orm.metaModel
Class MetaDatabase

java.lang.Object
  extended by org.ujorm.extensions.SuperAbstractUjo
      extended by org.ujorm.extensions.AbstractUjo
          extended by org.ujorm.orm.AbstractMetaModel
              extended by org.ujorm.orm.metaModel.MetaDatabase
All Implemented Interfaces:
Serializable, Comparable<MetaDatabase>, UjoCloneable, UjoLockable, UjoTextable, Ujo

public final class MetaDatabase
extends AbstractMetaModel
implements Comparable<MetaDatabase>

A logical database description.

See Also:
Serialized Form

Field Summary
static Key<MetaDatabase,Class<? extends SqlDialect>> DIALECT
          SQL dialect type of Class<SqlDialect>
static Key<MetaDatabase,String> ID
          The meta-model id
static Key<MetaDatabase,String> JDBC_DRIVER
          JDBC Driver
static Key<MetaDatabase,String> JDBC_URL
          JDBC URL connection
static ListKey<MetaDatabase,String> JNDI
          JNDI (java naming and directory interface) connection string
static Key<MetaDatabase,Integer> ORDER
          Database order number
static Key<MetaDatabase,Orm2ddlPolicy> ORM2DLL_POLICY
          A policy to defining the database structure by a DDL.
static Key<MetaDatabase,String> PASSWORD
          DB password of the user
static ListKey<MetaDatabase,MetaProcedure> PROCEDURES
          List of procedures
static Key<MetaDatabase,Boolean> READ_ONLY
          The default state read-only for the database.
static Key<MetaDatabase,OrmUjo> ROOT
          An instance of the DB class.
static Key<MetaDatabase,String> SCHEMA
          MetaDatabase default schema
static Key<MetaDatabase,Class<? extends UjoSequencer>> SEQUENCER
          The sequencer class for tables of the current database.
static ListKey<MetaDatabase,MetaTable> TABLES
          List of tables
static Key<MetaDatabase,String> USER
          DB user
 
Constructor Summary
MetaDatabase()
           
MetaDatabase(OrmHandler ormHandler, OrmUjo database, MetaDatabase param, Integer order)
          Create a new Database.
 
Method Summary
 void changeDbLength(MetaColumn column)
          Change DbType by a Java key
 void changeDbType(MetaColumn column)
          Change DbType by a Java key
static void close(Connection connection, JdbcStatement statement, ResultSet rs, boolean throwExcepton)
          Close a connection, statement and a result set.
static void close(Connection connection, Statement statement, ResultSet rs, boolean throwExcepton)
          Close a connection, statement and a result set.
 int compareTo(MetaDatabase o)
          Compare the object by ORDER.
 void create(Session session)
          Create DB
 Connection createConnection()
          Create connection with auto-commit false.
 Connection createInternalConnection()
          Call the method from SqlDialect only.
protected  UjoSequencer createSequencer(MetaTable table)
          Create a new sequencer for selected table
 MetaDbService createService()
          Create a service method
 boolean equals(Object obj)
          Equals
 Session getDefaultSession()
          Returns a default handler session.
 SqlDialect getDialect()
          Returns a SQL dialect for the current database.
 String getId()
          Returns an ID of the MetaDatabase.
 List<MetaIndex> getIndexList()
          Returns all database indexes
 OrmHandler getOrmHandler()
          OrmHandler
 MetaParams getParams()
          Return the OrmHandler parameters
 Set<String> getSchemas(List<MetaTable> tables)
          Get all table schemas
 int getTableTotalCount()
          Returns a full count of the database tables (views are excluded)
 int hashCode()
          Hash code
 boolean isSequenceTableRequired()
          Method returns true in case any table requires the internal table 'ujorm_pk_support' to get a next sequence value.
 boolean readAuthorization(UjoAction action, Key key, Object value)
          The PASSWORD key is not exported to XML for a better security.
 String toString()
           
 
Methods inherited from class org.ujorm.orm.AbstractMetaModel
changeDefault, checkReadOnly, clearReadOnly, get, lock, readOnly, setReadOnly, writeValue
 
Methods inherited from class org.ujorm.extensions.AbstractUjo
newCamelFactory, newFactory, readValue
 
Methods inherited from class org.ujorm.extensions.SuperAbstractUjo
clone, init, init, readKeys, readUjoManager, readValueString, writeValueString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ujorm.Ujo
readKeys, readValue
 

Field Detail

ID

public static final Key<MetaDatabase,String> ID
The meta-model id


SCHEMA

public static final Key<MetaDatabase,String> SCHEMA
MetaDatabase default schema


READ_ONLY

public static final Key<MetaDatabase,Boolean> READ_ONLY
The default state read-only for the database.


DIALECT

public static final Key<MetaDatabase,Class<? extends SqlDialect>> DIALECT
SQL dialect type of Class<SqlDialect>


JDBC_URL

public static final Key<MetaDatabase,String> JDBC_URL
JDBC URL connection


JDBC_DRIVER

public static final Key<MetaDatabase,String> JDBC_DRIVER
JDBC Driver


USER

public static final Key<MetaDatabase,String> USER
DB user


PASSWORD

public static final Key<MetaDatabase,String> PASSWORD
DB password of the user


JNDI

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


SEQUENCER

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


ORM2DLL_POLICY

public static final Key<MetaDatabase,Orm2ddlPolicy> ORM2DLL_POLICY
A policy to defining the database structure by a DDL.

See Also:
Parameter values

TABLES

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


PROCEDURES

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


ORDER

public static final Key<MetaDatabase,Integer> ORDER
Database order number


ROOT

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

Constructor Detail

MetaDatabase

public MetaDatabase()

MetaDatabase

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

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

createService

public MetaDbService createService()
                            throws IllegalStateException
Create a service method

Throws:
IllegalStateException

getDialect

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


changeDbType

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

Parameters:
column - Column model

changeDbLength

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


getTableTotalCount

public int getTableTotalCount()
Returns a full count of the database tables (views are excluded)


create

public void create(Session session)
Create DB


close

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

Throws:
IllegalStateException

close

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

Throws:
IllegalStateException

getOrmHandler

public OrmHandler getOrmHandler()
OrmHandler


getParams

public MetaParams getParams()
Return the OrmHandler parameters


getId

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


createConnection

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

Throws:
Exception

createInternalConnection

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

Throws:
Exception

equals

public boolean equals(Object obj)
Equals

Overrides:
equals in class SuperAbstractUjo

hashCode

public int hashCode()
Hash code

Overrides:
hashCode in class Object

getDefaultSession

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


getSchemas

public Set<String> getSchemas(List<MetaTable> tables)
Get all table schemas


isSequenceTableRequired

public boolean isSequenceTableRequired()
Method returns true in case any table requires the internal table 'ujorm_pk_support' to get a next sequence value.


createSequencer

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


getIndexList

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


toString

public String toString()
Overrides:
toString in class SuperAbstractUjo

compareTo

public int compareTo(MetaDatabase o)
Compare the object by ORDER.

Specified by:
compareTo in interface Comparable<MetaDatabase>

readAuthorization

public boolean readAuthorization(UjoAction action,
                                 Key key,
                                 Object value)
The PASSWORD key is not exported to XML for a better security.

Specified by:
readAuthorization in interface Ujo
Overrides:
readAuthorization in class AbstractMetaModel


Copyright 2013, Pavel Ponec