org.apache.ojb.broker.accesslayer
Class JdbcAccessImpl

java.lang.Object
  extended by org.apache.ojb.broker.accesslayer.JdbcAccessImpl
All Implemented Interfaces:
JdbcAccess

public class JdbcAccessImpl
extends Object
implements JdbcAccess

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

Version:
$Id: JdbcAccessImpl.java,v 1.1 2007-08-24 22:17:30 ewestfal Exp $
Author:
Thomas Mahler

Field Summary
protected  PersistenceBroker broker
          The broker in use.
protected  Logger logger
          The logger used.
 
Constructor Summary
JdbcAccessImpl(PersistenceBroker broker)
          constructor is private, use getInstance to get the singleton instance of this class
 
Method Summary
private  ValueContainer[] addValues(ValueContainer[] target, ValueContainer[] source)
          Helper method, returns the addition of both arrays (add source to target array)
protected  void assignAutoincrementIdentityColumns(ClassDescriptor cld, Object target)
           
protected  void assignAutoincrementSequences(ClassDescriptor cld, Object target)
           
 void executeDelete(ClassDescriptor cld, Object obj)
          performs a DELETE operation against RDBMS.
 void executeDelete(Query query, ClassDescriptor cld)
          Performs a DELETE operation based on the given Query against RDBMS.
 void executeInsert(ClassDescriptor cld, Object obj)
          performs an INSERT operation against RDBMS.
 ResultSetAndStatement executeQuery(Query query, ClassDescriptor cld)
          performs a SELECT operation against RDBMS.
 ResultSetAndStatement executeSQL(String sqlStatement, ClassDescriptor cld, boolean scrollable)
          performs a SQL SELECT statement against RDBMS.
 ResultSetAndStatement executeSQL(String sql, ClassDescriptor cld, ValueContainer[] values, boolean scrollable)
          performs a SQL SELECT statement against RDBMS.
 void executeUpdate(ClassDescriptor cld, Object obj)
          performs an UPDATE operation against RDBMS.
 int executeUpdateSQL(String sqlStatement, ClassDescriptor cld)
          performs a SQL UPDTE, INSERT or DELETE statement against RDBMS.
 int executeUpdateSQL(String sqlStatement, ClassDescriptor cld, ValueContainer[] values1, ValueContainer[] values2)
          performs a SQL UPDTE, INSERT or DELETE statement against RDBMS.
private  Platform getPlatform()
          Helper Platform accessor method
private  void harvestReturnValue(Object obj, CallableStatement callable, FieldDescriptor fmd, int index)
          Harvest a single value that was returned by a callable statement.
private  void harvestReturnValues(ProcedureDescriptor proc, Object obj, PreparedStatement stmt)
          Harvest any values that may have been returned during the execution of a procedure.
protected  boolean isStoredProcedure(String sql)
          Check if the specified sql-string is a stored procedure or not.
 Object materializeObject(ClassDescriptor cld, Identity oid)
          performs a primary key lookup operation against RDBMS and materializes an object from the resulting row.
private  void setLockingValues(ClassDescriptor cld, Object obj, ValueContainer[] oldLockingValues)
          Set the locking values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected Logger logger
The logger used.


broker

protected PersistenceBroker broker
The broker in use.

Constructor Detail

JdbcAccessImpl

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

Method Detail

getPlatform

private Platform getPlatform()
Helper Platform accessor method

Returns:
Platform for the current broker connection manager.

executeDelete

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

Specified by:
executeDelete in interface JdbcAccess
Parameters:
cld - ClassDescriptor providing mapping information.
obj - The object to be deleted.
Throws:
PersistenceBrokerException

executeDelete

public void executeDelete(Query query,
                          ClassDescriptor cld)
                   throws PersistenceBrokerException
Performs a DELETE operation based on the given Query against RDBMS.

Specified by:
executeDelete in interface JdbcAccess
Parameters:
query - the query string.
cld - ClassDescriptor providing JDBC information.
Throws:
PersistenceBrokerException

executeInsert

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

Specified by:
executeInsert in interface JdbcAccess
Parameters:
obj - The Object to be inserted as a row of the underlying table.
cld - ClassDescriptor providing mapping information.
Throws:
PersistenceBrokerException

executeQuery

public ResultSetAndStatement executeQuery(Query query,
                                          ClassDescriptor cld)
                                   throws PersistenceBrokerException
performs a SELECT operation against RDBMS.

Specified by:
executeQuery in interface JdbcAccess
Parameters:
query - the query string.
cld - ClassDescriptor providing JDBC information.
Throws:
PersistenceBrokerException

executeSQL

public ResultSetAndStatement executeSQL(String sqlStatement,
                                        ClassDescriptor cld,
                                        boolean scrollable)
                                 throws PersistenceBrokerException
Description copied from interface: JdbcAccess
performs a SQL SELECT statement against RDBMS.

Specified by:
executeSQL in interface JdbcAccess
Parameters:
sqlStatement - the query string.
cld - ClassDescriptor providing meta-information.
scrollable - Does this resultset need cursor control for operations like last, first and size
Throws:
PersistenceBrokerException

executeSQL

public ResultSetAndStatement executeSQL(String sql,
                                        ClassDescriptor cld,
                                        ValueContainer[] values,
                                        boolean scrollable)
                                 throws PersistenceBrokerException
performs a SQL SELECT statement against RDBMS.

Specified by:
executeSQL in interface JdbcAccess
Parameters:
sql - the query string.
cld - ClassDescriptor providing meta-information.
values - The set of values to bind to the statement (may be null)
scrollable - Does this resultset need cursor control for operations like last, first and size
Throws:
PersistenceBrokerException

executeUpdateSQL

public int executeUpdateSQL(String sqlStatement,
                            ClassDescriptor cld)
                     throws PersistenceBrokerException
Description copied from interface: JdbcAccess
performs a SQL UPDTE, INSERT or DELETE statement against RDBMS.

Specified by:
executeUpdateSQL in interface JdbcAccess
Parameters:
sqlStatement - the query string.
cld - ClassDescriptor providing meta-information.
Returns:
int returncode
Throws:
PersistenceBrokerException

executeUpdateSQL

public int executeUpdateSQL(String sqlStatement,
                            ClassDescriptor cld,
                            ValueContainer[] values1,
                            ValueContainer[] values2)
                     throws PersistenceBrokerException
performs a SQL UPDTE, INSERT or DELETE statement against RDBMS.

Specified by:
executeUpdateSQL in interface JdbcAccess
Parameters:
sqlStatement - the query string.
cld - ClassDescriptor providing meta-information.
values1 - The first set of values to bind to the statement (may be null)
values2 - The second set of values to bind to the statement (may be null)
Returns:
int returncode
Throws:
PersistenceBrokerException

addValues

private ValueContainer[] addValues(ValueContainer[] target,
                                   ValueContainer[] source)
Helper method, returns the addition of both arrays (add source to target array)


executeUpdate

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

Specified by:
executeUpdate in interface JdbcAccess
Parameters:
obj - The Object to be updated in the underlying table.
cld - ClassDescriptor providing mapping information.
Throws:
PersistenceBrokerException

materializeObject

public Object materializeObject(ClassDescriptor cld,
                                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.

Specified by:
materializeObject in interface JdbcAccess
Parameters:
oid - contains the primary key info.
cld - ClassDescriptor providing mapping information.
Returns:
the materialized object, null if no matching row was found or if any error occured.
Throws:
PersistenceBrokerException

setLockingValues

private void setLockingValues(ClassDescriptor cld,
                              Object obj,
                              ValueContainer[] oldLockingValues)
Set the locking values

Parameters:
cld -
obj -
oldLockingValues -

harvestReturnValues

private void harvestReturnValues(ProcedureDescriptor proc,
                                 Object obj,
                                 PreparedStatement stmt)
                          throws PersistenceBrokerSQLException
Harvest any values that may have been returned during the execution of a procedure.

Parameters:
proc - the procedure descriptor that provides info about the procedure that was invoked.
obj - the object that was persisted
stmt - the statement that was used to persist the object.
Throws:
PersistenceBrokerSQLException - if a problem occurs.

harvestReturnValue

private void harvestReturnValue(Object obj,
                                CallableStatement callable,
                                FieldDescriptor fmd,
                                int index)
                         throws PersistenceBrokerSQLException
Harvest a single value that was returned by a callable statement.

Parameters:
obj - the object that will receive the value that is harvested.
callable - the CallableStatement that contains the value to harvest
fmd - the FieldDescriptor that identifies the field where the harvested value will be stord.
index - the parameter index.
Throws:
PersistenceBrokerSQLException - if a problem occurs.

isStoredProcedure

protected boolean isStoredProcedure(String sql)
Check if the specified sql-string is a stored procedure or not.

Parameters:
sql - The sql query to check
Returns:
True if the query is a stored procedure, else false is returned.

assignAutoincrementSequences

protected void assignAutoincrementSequences(ClassDescriptor cld,
                                            Object target)
                                     throws SequenceManagerException
Throws:
SequenceManagerException

assignAutoincrementIdentityColumns

protected void assignAutoincrementIdentityColumns(ClassDescriptor cld,
                                                  Object target)
                                           throws SequenceManagerException
Throws:
SequenceManagerException


Copyright © 2007-2011 The Kuali Foundation. All Rights Reserved.