db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "J. Russell Smyth" <drf...@cox.net>
Subject Bug found, need input before submitting fix
Date Thu, 12 Dec 2002 07:30:20 GMT
We have stumbled across an interesting problem. 

In our application, we have two tables/objects, each which have an "ID"
column, which is our OID for the particular object. 

We have been having a bear of a time with a query that joins these two
tables.. we finally tracked the problem to the identically named
columns. Inside DefaultRowReader, when the JdbcAccess class is used to
turn a row into an object, it does JdbcAccess.getObjectFromColumn, which
in turn calls ResultSet.getXXX( columnId ). This is where the problem

In our case, there are now two "ID" columns in the result set. so when
OJB is trying to populate our first object (call it object A) it does 
rs.getInt( "ID" ). when populating object B, it will do the same thing -
obviously the result for one or the other will be wrong!

In our case, some bad mojo in the way that SAPDB hashes the column
identifiers insured us getting the wrong ide placed into object A,
making the problem abundantly clear.

My co-worker has written a temporary fix that simply aliases all columns
in a query as TABLE_COLUMN in 

by adding

 "AS [field.getClassDescriptor().getFullTableName())]_[field.getColumnName())]"

to each column descriptor in the query 
("select A0.ID AS TAB1_ID, A1.ID AS TAB2_ID from TAB1 A0, TAB2 A1 WHERE .... ")

and made  org.apache.ojb.broker.accesslayer.JdbcAccess look for
this name by changing
fld.getClassDescriptor().getFullTableName() + "_" + fld.getColumnName()

I have begun to write a test case, and am looking to see if there is a 
cleaner way to do this, but I wanted to get input from the group before
I went to far - perhaps someone with more experience with the OJB
internals can see a better fix faster than i, or has even run into this

If not, I would still welcome any input, and will continue to work on
test case and fix.


View raw message