ojb.broker.accesslayer
Class JdbcAccess

java.lang.Object
  |
  +--ojb.broker.accesslayer.JdbcAccess

public class JdbcAccess
extends java.lang.Object

JdbcAccess is responsible for establishing performing SQL Queries against remote Databases. It hides all knowledge about JDBC from the BrokerImpl

Author:
Thomas Mahler

Constructor Summary
JdbcAccess(PersistenceBrokerImpl broker)
          constructor is private, use getInstance to get the singleton instance of this class
 
Method Summary
 int executeCount(Query query, ClassDescriptor mif)
          performs a SELECT COUNT(*) operation against RDBMS.
 void executeDelete(ClassDescriptor mif, java.lang.Object obj)
          performs a DELETE operation against RDBMS.
 void executeInsert(ClassDescriptor mif, java.lang.Object obj)
          performs an INSERT operation against RDBMS.
(package private)  java.sql.ResultSet executeQuery(Query query, ClassDescriptor mif)
          performs a SELECT operation against RDBMS.
(package private)  java.sql.ResultSet executeSQL(java.lang.String sqlStatement, ClassDescriptor cld)
          performs a SQL SELECT statement against RDBMS.
 void executeUpdate(ClassDescriptor mif, java.lang.Object obj)
          performs an UPDATE operation against RDBMS.
 int executeUpdateSQL(java.lang.String sqlStatement, ClassDescriptor cld)
          performs a SQL UPDTE, INSERT or DELETE statement against RDBMS.
(package private) static java.lang.Object getObjectFromColumn(java.sql.ResultSet rs, FieldDescriptor fld)
          retrieves an Object from a ResultSet column.
(package private) static java.lang.Object getObjectFromColumn(java.sql.ResultSet rs, int jdbcType, int columnId)
           
(package private) static int getSqlTypeAll(ClassDescriptor cld, int index)
          determines the JDBC type (represented as an int value as specified by java.sql.Types) of a FieldDescriptor idetified by index.
(package private) static int getSqlTypeNonPk(ClassDescriptor cld, int index)
          determines the JDBC type (represented as an int value as specified by java.sql.Types) of a FieldDescriptor idetified by index.
(package private) static int getSqlTypePk(ClassDescriptor cld, int index)
          determines the JDBC type (represented as an int value as specified by java.sql.Types) of a FieldDescriptor idetified by index.
 java.lang.Object materializeObject(ClassDescriptor mif, Identity oid)
          performs a primary key lookup operation against RDBMS and materializes an object from the resulting row.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdbcAccess

public JdbcAccess(PersistenceBrokerImpl broker)
constructor is private, use getInstance to get the singleton instance of this class

Method Detail

executeCount

public int executeCount(Query query,
                        ClassDescriptor mif)
                 throws PersistenceBrokerException
performs a SELECT COUNT(*) operation against RDBMS. BRJ

Parameters:
query - the query string.
mif - ClassDescriptor providing JDBC information.
PersistenceBrokerException

executeDelete

public void executeDelete(ClassDescriptor mif,
                          java.lang.Object obj)
                   throws PersistenceBrokerException
performs a DELETE operation against RDBMS.

Parameters:
mif - ClassDescriptor providing mapping information.
obj - The object to be deleted.
PersistenceBrokerException

executeInsert

public void executeInsert(ClassDescriptor mif,
                          java.lang.Object obj)
                   throws PersistenceBrokerException
performs an INSERT operation against RDBMS.

Parameters:
obj - The Object to be inserted as a row of the underlying table.
mif - ClassDescriptor providing mapping information.
PersistenceBrokerException

executeQuery

java.sql.ResultSet executeQuery(Query query,
                                ClassDescriptor mif)
                          throws PersistenceBrokerException
performs a SELECT operation against RDBMS.

Parameters:
query - the query string.
mif - ClassDescriptor providing JDBC information.
PersistenceBrokerException

executeSQL

java.sql.ResultSet executeSQL(java.lang.String sqlStatement,
                              ClassDescriptor cld)
                        throws PersistenceBrokerException
performs a SQL SELECT statement against RDBMS.

Parameters:
sqlStatement - the query string.
cld - ClassDescriptor providing meta-information.
PersistenceBrokerException

executeUpdateSQL

public int executeUpdateSQL(java.lang.String sqlStatement,
                            ClassDescriptor cld)
                     throws PersistenceBrokerException
performs a SQL UPDTE, INSERT or DELETE statement against RDBMS.

Parameters:
sqlStatement - the query string.
cld - ClassDescriptor providing meta-information.
Returns:
int returncode
PersistenceBrokerException

executeUpdate

public void executeUpdate(ClassDescriptor mif,
                          java.lang.Object obj)
                   throws PersistenceBrokerException
performs an UPDATE operation against RDBMS.

Parameters:
obj - The Object to be updated in the underlying table.
mif - ClassDescriptor providing mapping information.
PersistenceBrokerException

materializeObject

public java.lang.Object materializeObject(ClassDescriptor mif,
                                          Identity oid)
                                   throws PersistenceBrokerException
performs a primary key lookup operation against RDBMS and materializes an object from the resulting row. Only skalar attributes are filled from the row, references are not resolved.

Parameters:
oid - contains the primary key info.
mif - ClassDescriptor providing mapping information.
Returns:
the materialized object, null if no matching row was found or if any error occured.
PersistenceBrokerException

getObjectFromColumn

static java.lang.Object getObjectFromColumn(java.sql.ResultSet rs,
                                            FieldDescriptor fld)
                                     throws java.sql.SQLException
retrieves an Object from a ResultSet column.

Parameters:
rs - the ResultSet to be read from.
fld - The FieldDescriptor containing metainfo on the column: it contins info on the expected JDBC Type and the name of the column.
Returns:
Object the read in object.
java.sql.SQLException

getObjectFromColumn

static java.lang.Object getObjectFromColumn(java.sql.ResultSet rs,
                                            int jdbcType,
                                            int columnId)
                                     throws java.sql.SQLException
java.sql.SQLException

getSqlTypeAll

static int getSqlTypeAll(ClassDescriptor cld,
                         int index)
determines the JDBC type (represented as an int value as specified by java.sql.Types) of a FieldDescriptor idetified by index.

Parameters:
cld - The ClassDescriptor containing the FieldDescriptor.
index - index identifies the FieldDescriptor within cld.
Returns:
the int value representing the Type according to java.sql.Types

getSqlTypeNonPk

static int getSqlTypeNonPk(ClassDescriptor cld,
                           int index)
determines the JDBC type (represented as an int value as specified by java.sql.Types) of a FieldDescriptor idetified by index.

Parameters:
cld - The ClassDescriptor containing the FieldDescriptor.
index - index identifies the FieldDescriptor within the Non-PrimaryKey-fields of cld.
Returns:
the int value representing the Type according to java.sql.Types

getSqlTypePk

static int getSqlTypePk(ClassDescriptor cld,
                        int index)
determines the JDBC type (represented as an int value as specified by java.sql.Types) of a FieldDescriptor idetified by index.

Parameters:
cld - The ClassDescriptor containing the FieldDescriptor.
index - index identifies the FieldDescriptor within the PrimaryKey-fields of cld.
Returns:
the int value representing the Type according to java.sql.Types


Authors: Thomas Mahler and others. (C) 2000, 2001.
All rights reserved. Published under the Gnu Public License.
http://objectbridge.sourceforge.net
Version: 0.8.375, 2002-04-04