db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oystein Grovlen - Sun Norway <Oystein.Grov...@Sun.COM>
Subject Re: Questions about CallableLocatorProcedures.java
Date Fri, 18 May 2007 17:18:33 GMT
Knut Anders Hatlen wrote:
> "Kristian Waagan (JIRA)" <jira@apache.org> writes:
>> Committed 'blobframework_v2.diff' to trunk with revision 529185.
>> Very nicely commented patch Øystein!
> OK, so I'm more than three weeks late to review the patch... :)
> Anyway, I came across CallableLocatorProcedures.java and a couple of
> questions came to mind:
> A) It seems to contain a lot of almost identical code for CLOBs and
> BLOBs. Would it make sense to reuse some of it instead of duplicating
> it? For instance, blobCreateLocator() and clobCreateLocator() have
> exactly the same structure, and could have been written as a generic
> lobCreateLocator() which took a CallableStatement, the SQL text and the
> holdability as parameters. blobCreateLocator() and clobCreateLocator()
> could be just wrappers are around the generic method. The same comment
> also applies to [bc]lobReleaseLocator, [bc]lobGetPositionFromLocator,
> [bc]lobGetLength and [bc]lobTruncate. I think this could reduce the size
> of the file considerably, and it would also be easier to maintain it.

I agree that this should be considered.  When I created the file there 
was not much logic except calling the underlying stored procedures, and
the most straight-forward way of doing this was to start with a list of 
methods to implement and just use a macro to generate code for all the 

However, later more logic has been added and I agree that it would be 
good if that logic could be shared.  The ironi is that the those "sister 
methods" that have most of "extra logic", cannot share implementation 
since they operate on different data types (byte arrays vs. String).

I will put rewriting this class on my list, but I need to prioritize 
getting locators to run without failures first.

> B) Why does blobCreateLocator() get the holdability from the connection,
> whereas clobCreateLocator() always uses non-holdable cursors?

This kind of proves your point. :-) I do not see any reason for this 
difference.  Holdability would not matter here, anyway.


View raw message