db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Mahler <thm...@web.de>
Subject Re: OJB: Support for invoking stored procedures
Date Tue, 09 Sep 2003 19:07:13 GMT
Hi Ron,

Ron Gallagher wrote:
> Thomas --
> I found and fixed the problem that was causing the
> NullPointerExceptions.  The attached file contains the update.  The
> only change was in StatementsForClassImpl.java, but I'm sending you
> the full update just to be 'safe'.

thanks for the patch, now everything works fine!
I've just checked it into our CVS!

> If you feel these changes are suitable for inclusion in the core api,
> I'll start working on updating the 'how-to' related to stored
> procedures so that it utilizes these new capabilities.

Yes, having some kind of howto would be great. I'll update the 
repository.xml documentation to include your additions to the DTD.

Thanks for the good work to both of you!
- Thomas

> Ron Gallagher Atlanta, GA rongallagher@bellsouth.net
>> From: Thomas Mahler <thma32@web.de> Date: 2003/09/07 Sun AM
>> 11:56:45 EDT To: Ron Gallagher <rgallagh@bellsouth.net> Subject:
>> Re: OJB: Support for invoking stored procedures
>> Hi Ron,
>> Ron Gallagher wrote:
>>> Thomas --
>>> Randall Burt and I have been working on enhancements to OJB that
>>> will allow it to allow the use of procedures/functions for
>>> insert, update and delete operations.  The attached file contains
>>> the result of that effort.
>> The code looks great. everything is properly designed and ready for
>>  check in! thanks for all your efforts.
>> But I have some trouble in running the junit tests after applying
>> your changes. A lot of testcases crash with the following
>> stacktrace:
> <snip>
>>> Below is a basic overview of the classes/files that were created
>>> or modified in order to support this capability.
>>> The attached zip file contains the updated or new files .
>>> A few comments about our implementation:
>>> 1) We're using the term 'procedure' throughout the
>>> implementation. In the Oracle world, there is a difference
>>> between a 'function' and a 'procedure'.  A function has a return
>>> value.  A procedure doesn't. Our implementation supports the
>>> invocation of both types of entities. I tried to come up with a
>>> term that encompassed both types of entities but didn't use
>>> either term (procedure or function).  I really couldn't come up
>>> with one.  If you have a suggestion, I'd be more than willing to
>>> refactor the implementation to incorporate your suggestion.
>> IMO "procedure" is fine because it's the generally accepted term.
>>> 2) I haven't looked into what impact, if any, this extension may
>>> have on the batch update capabilities within OJB.  I've started
>>> looking into it, but keep getting bogged down in the complexity
>>> of that process.  I'll keep trying to figure out the impact in
>>> this area, but it would be extremely helpful if one of the 'core'
>>> committers could take look at the batch update capabilities for
>>> any possible impact.
>> I'm not an expert in this area, but I don't see any principal
>> problems, as long as a stored procedure does not play around with
>> the ongoing transaction. I'll ask Oleg and Armin to have a closer
>> look at this...
>> 3) I'm still trying to figure out how to put
>>> together unit tests for this capability.  I've tested the 
>>> capabilities on my systems at home, but I haven't figured out how
>>> to incorporate tests into the unit tests that ship with OJB.  I
>>> welcome any suggestions that you may have.
>> The OJB testdatabase HSQLDB supports stored procedures. I've not
>> yet used this feature but there seems to be some documentation on
>> this subject in the hsqldb distro. I think this should be
>> sufficient to write some simple SPs for the CRUD operations.
>> thanks again for the good work!
>> cheers, Thomas
>>> I welcome any comments, feedback or suggestions.
>>> Ron Gallagher Atlanta, GA rongallagher@bellsouth.net
>>> Modified Files:
>>> JdbcAccessImpl ==============
>>> Added the harvestReturnValues method to handle the 'harvesting'
>>> of any return values that may have been returend by the procedure
>>> that was used to perform the requested persistence operation.
>>> Added code to the executeInsert, executeUpdate and executeDelete
>>> methods to call harvestReturnValues after the persistence
>>> operation is performed.
>>> StatementManager ================
>>> Added the bindProcedure method to handle the binding values for a
>>>  statement that invokes a stored procedure. Added code to the 
>>> bindInsert, bindUpdate and bindDelete methods to call
>>> bindProcedure if the ClassDescriptor has a procedure descriptor
>>> of the appropriate type.
>>> StatementsForClassImpl ======================
>>> Added an overloaded version of the prepareStatement method.  The
>>> new method includes an extra argument (createPreparedStatement)
>>> that is used to determine what type of statement
>>> (PreparedStatement or CallableStatement) to create. The existing
>>> prepareStatement method is now marked as deprecated.  It's
>>> implementation simple defers to the new version of
>>> prepareStatement, passing 'true' for the new 
>>> 'createPreparedStatement' argument. In the new version of the 
>>> prepareStatement method, all calls to 'con.prepareStatement' are 
>>> wrapped in the following pseudo-code: if
>>> (createPreparedStatement) { result = con.prepareStatement(...); }
>>> else { result = con.prepareCall(...); }
>>> SqlGeneratorDefaultImpl =======================
>>> In the getPreparedDeleteStatement method, create an instance of 
>>> SqlProcedureStatement if the ClassDescriptor has a delete
>>> procedure descriptor.  If there is no delete procedure
>>> descriptor, then create an instance of SqlDeleteByPkStatement. A
>>> similar change was also made to the getPreparedInsertStatement
>>> and getPreparedUpdate methods. Only, in those methods, we check
>>> for an insert or update procedure descriptor.
>>> ClassDescriptor ===============
>>> Added member variables as well as getters/setters for an 
>>> InsertProcedureDescriptor, UpdateProcedureDescriptor and 
>>> DeleteProcedureDescriptor. Enhanced the toXml method to handle
>>> the three new descriptors.
>>> RepositoryElements ================== Added constants for all of
>>> the elements/attributes that were added to support this
>>> capability.
>>> RepositoryTags ============== Added entries for all of the 
>>> elements/attributes that were added to support this capability.
>>> RepositoryXmlHandler ==================== Added code to the 
>>> startElement and endElement to handle the new elements that can 
>>> appear in the repository.
>>> SqlHelper ========= Added another overloaded version of the
>>> method 'getObjectFromColumn'.  This one receives a
>>> CallableStatment instead of a ResultSet.
>>> SqlTypeHelper ============= Added another overloaded version of
>>> the getObjectFromColumn method.  This one receives a
>>> CallableStatement instead of a ResultSet.  It is used to
>>> 'harvest' any values that are returned by a procedure.
>>> repository.dtd ============== Added support for the
>>> insert-procedure, update-procedure and delete-procedure elements
>>> within a class-descriptor element.  Each of these can appear 0 or
>>> 1 time. Added definitions for the following new elements: *
>>> insert-procedure * update-procedure * delete-procedure *
>>> runtime-argument * constant-argument
>>> New Files:
>>> SqlProcedureStatement ===================== Provides the sql
>>> syntax generation support when a procedure is used for an insert,
>>> update or delete operation.
>>> ArgumentDescriptor ================== Provides configuration for
>>> an argument that's passed to a procedure.
>>> ProcedureDescriptor =================== Base class for the 3 new 
>>> XxxProcedureDescriptor classes
>>> InsertProcedureDescriptor ========================= Provides 
>>> configuration for an insert procedure
>>> UpdateProcedureDescriptor ========================= Provides 
>>> configuration for an update procedure
>>> DeleteProcedureDescriptor ========================= Provides 
>>> configuration for a delete procedure

To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org

View raw message