org.opensubsystems.core.persist.db
Interface DatabaseSchema

All Known Subinterfaces:
ModifiableDatabaseSchema
All Known Implementing Classes:
DatabaseSchemaImpl, ModifiableDatabaseSchemaImpl, MSSQLVersionedDatabaseSchema, MySQLVersionedDatabaseSchema, PostgreSQLVersionedDatabaseSchema, SybaseVersionedDatabaseSchema, VersionedDatabaseSchema

public interface DatabaseSchema

Interface representing database schema, which is set of related database objects such as tables, constraints and indexes. One database instance will usually consists of multiple schemas coresponding to components used in the application. Each component or subsystem will provide one or multiple database schemas, which will be responsible for creation of all database structures for this components, for the upgrade of existing database structures to the latest version and also will encapsulate all specific database dependent information (such as database dependent queries).

Version:
$Id: DatabaseSchema.java,v 1.14 2007/01/10 05:10:44 bastafidli Exp $
Author:
Miro Halas
Code reviewer:
Miro Halas
Code reviewed:
1.6 2006/07/21 22:47:38 jlegeny

Method Summary
 void create(java.sql.Connection cntDBConnection, java.lang.String strUserName)
          Create the schema.
 DatabaseSchema[] getDependentSchemas()
          Get list of database schemas which this schema depends on.
 java.lang.String getName()
          Get the name of this database schema.
 int getVersion()
          Get the current (most recent) version of database schema.
 void handleSQLException(java.sql.SQLException exc, java.sql.Connection dbConnection, int iOperationType, int iDataType, java.lang.Object data)
          Handle SQL Exception caused by some database operations.
 boolean isInDomain()
          Check if the the data object belongs to a domain or not.
 void upgrade(java.sql.Connection cntDBConnection, java.lang.String strUserName, int iOriginalVersion)
          Upgrade the schema.
 

Method Detail

getName

java.lang.String getName()
Get the name of this database schema.

Returns:
String - name which uniquely identifies this schema.

getVersion

int getVersion()
Get the current (most recent) version of database schema.

Returns:
int - most current version of the schema

isInDomain

boolean isInDomain()
Check if the the data object belongs to a domain or not. If data object belongs to a domain, its table contains DOMAIN_ID column, which should be checked in generated SQL for this data type against the current call context domain. The assumption is that if the schema is managing multiple data objects and one of them is in domain then all of them are in domain (and vice versa) since it doesn't make sense for closely related data objects to do not exists in the same domain at the same time.

Returns:
boolean - true if data object belongs to domain, false otherwise

create

void create(java.sql.Connection cntDBConnection,
            java.lang.String strUserName)
            throws java.sql.SQLException,
                   OSSException
Create the schema.

Parameters:
cntDBConnection - - valid connection to database
strUserName - - name of user who will be accessing this table
Throws:
java.sql.SQLException - - problem creating the database schema
OSSException - - problem creating the database schema

upgrade

void upgrade(java.sql.Connection cntDBConnection,
             java.lang.String strUserName,
             int iOriginalVersion)
             throws java.sql.SQLException
Upgrade the schema.

Parameters:
cntDBConnection - - valid connection to database
strUserName - - name of user who will be accessing this table
iOriginalVersion - - original version from which to upgrade
Throws:
java.sql.SQLException - - problem creating the database schema

getDependentSchemas

DatabaseSchema[] getDependentSchemas()
                                     throws OSSException
Get list of database schemas which this schema depends on. These schemas will be created and initialized before this schema is initialized. This way if this schema has relationships (foreign keys, stored procedure access) with the other schemas, they are guaranteed to exist before this schema is created.

Returns:
DatabaseSchema[] - array of DatabaseSchema instances
Throws:
OSSException - - database cannot be started.

handleSQLException

void handleSQLException(java.sql.SQLException exc,
                        java.sql.Connection dbConnection,
                        int iOperationType,
                        int iDataType,
                        java.lang.Object data)
                        throws OSSException
Handle SQL Exception caused by some database operations.

Parameters:
exc - - sql exception to be handled
dbConnection - - database connection used when the exception occured
iOperationType - - type of the operation that caused the exception, see DatabaseOperations for possible values
iDataType - - data type the data object represents (e.g if this is type user and data is Integer, that means it is id of user object). This is one of the DataConstant constants.
data - - data object the exception is handled for
Throws:
OSSException - - problem handling exception


Copyright © 2003 - 2006 OpenSubsystems s.r.o.