db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Anthony <charles.anth...@hpdsoftware.com>
Subject RE: Modification request
Date Mon, 09 Aug 2004 08:03:47 GMT
Hi Armin, 

Thankyou.

Cheers,

Charles.



> -----Original Message-----
> From: Armin Waibel [mailto:arminw@apache.org]
> Sent: 09 August 2004 08:55
> To: OJB Developers List
> Subject: Re: Modification request
> 
> 
> Hi Charles,
> 
> checked in your patch in CVS (trunk + branch).
> 
> regards,
> Armin
> 
> Charles Anthony wrote:
> > Hi All,
> > 
> > EXPLANATION :
> > 
> > We've got a problem with the RowReaderDefaultImpl on some 
> of our tables,
> > which arises when we use the Microsoft SqlServer Driver and 
> the table
> > includes a LONGVARCHAR (or LONGVARBINARY).
> > 
> > The MS Driver doesn't like the columns resultset being read 
> twice (or out of
> > sequence) when the data include an IMAGE or TEXT column; you get the
> > following error (trimmed stackstrace): 
> > 
> > Caused by: java.sql.SQLException: [Microsoft][SQLServer 
> 2000 Driver for
> > JDBC]ResultSet can not re-read row data for column 1.
> > 	at 
> com.microsoft.jdbc.base.BaseExceptions.createException(Unknown
> > Source)
> > 	at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown
> > Source)
> > 	at 
> com.microsoft.jdbc.base.BaseResultSet.validateColumnIndex(Unknown
> > Source)
> > 	at 
> com.microsoft.jdbc.base.BaseResultSet.getString(Unknown Source)
> > 	at 
> com.microsoft.jdbc.base.BaseResultSet.getString(Unknown Source)
> > 	at 
> com.p6spy.engine.spy.P6ResultSet.getString(P6ResultSet.java:224)
> > 	at
> > 
> org.apache.ojb.broker.util.JdbcTypesHelper$T_Varchar.readValue
> FromResultSet(
> > JdbcTypesHelper.java:384)
> > 	at
> > 
> org.apache.ojb.broker.util.JdbcTypesHelper$BaseType.getObjectF
> romColumn(Jdbc
> > TypesHelper.java:308)
> > 	at
> > 
> org.apache.ojb.broker.util.JdbcTypesHelper$BaseType.getObjectF
> romColumn(Jdbc
> > TypesHelper.java:287)
> > 	at
> > 
> org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.readVal
> uesFrom(RowRea
> > derDefaultImpl.java:199)
> > 	... 20 more
> > 
> > The reason, spurious though it may be, is documented here :
> > http://support.microsoft.com/default.aspx?kbid=824106
> > 
> > The reason it throws this error is because the Default row 
> reader first
> > reads the PK to check the cache, and then if nothing is 
> found, reads the
> > entire row, thus leading to columns being read twice.
> > 
> > So, I'm writing a custom HPDRowReader that reads all the 
> columns into the
> > map in one go - and that only adds something to row map if 
> the column is't
> > already in the map. It looks like this :
> > 
> > public class HPDRowReader extends RowReaderDefaultImpl {
> > [...]
> > 
> >    public void readPkValuesFrom(ResultSet rs, Map row) {
> >      readObjectArrayFrom(rs, row);
> >    }
> > 
> >    protected void readValuesFrom(ResultSet rs, Map row, 
> FieldDescriptor[]
> > fields) {
> > 
> >     Object val = null;
> >     FieldDescriptor fld = null;
> >     try {
> >       for (int i = 0; i < fields.length; i++) {
> > 
> >         fld = fields[i];
> >         String columnName = fld.getColumnName();
> >         if (!row.containsKey(columnName)) {
> >           val = fld.getJdbcType().getObjectFromColumn(rs, 
> columnName);
> >           row.put(columnName, 
> fld.getFieldConversion().sqlToJava(val));
> >         }
> >       }
> > [...]
> > 
> > 
> > All's lovely and good - save that the RsIterator doesn't 
> clear down the map
> > as it moves between rows.
> > 
> > If I add change the RsIterator.getObjectFromResultSet() to 
> start like this :
> > 
> > protected Object getObjectFromResultSet {
> >    getRow().clear();
> >  
> > 
> getQueryObject().getClassDescriptor().getRowReader().readPkVal
> uesFrom(getRsA
> > ndStmt().m_rs, getRow());
> > 
> > Everthing works well.
> > 
> > REQUEST FOR MOD:
> > 
> > I can't see that this would negatively impact anything 
> else, so please Could
> > you add the getRow().clear call to the 
> RsIterator.getobjectFromReaultSet
> > method.
> > 
> > Cheers,
> > 
> > Charles.
> > 
> > 
> > ___________________________________________________________
> > HPD Software Ltd. - Helping Business Finance Business
> > Email terms and conditions: www.hpdsoftware.com/disclaimer 
> > 
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> > For additional commands, e-mail: ojb-dev-help@db.apache.org
> > 
> > 
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 


___________________________________________________________
HPD Software Ltd. - Helping Business Finance Business
Email terms and conditions: www.hpdsoftware.com/disclaimer 



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


Mime
View raw message