Hi, Between 1.0.0 and 1.0.1, some improvements were made to reading rowsets. The result was that columns were being read twice - and the MSSql jdbc driver throws a hissy fit if columns are re-read when there's a blob (or longvarchar or something similar) in the resultset.
To get round this, we created our own custom RowReader subclass that avoids this. Feel free to use this code as you will. To use the replace row-reader, change the entry OJB.properties to refer to the new class. #RowReaderDefaultClass=org.apache.ojb.broker.accesslayer.RowReaderDefaultImp l RowReaderDefaultClass=techframework.persistence.HPDRowReader Another option may be to try using jTds (http://jtds.sourceforge.net/) instead of the MS driver. We're using jtds, but I've not tried using the defuault RowReader with JTDS - as what ew've got works for us. HTH, Cheers, Charles. package techframework.persistence; import org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl; import org.apache.ojb.broker.metadata.ClassDescriptor; import org.apache.ojb.broker.metadata.FieldDescriptor; import org.apache.ojb.broker.PersistenceBrokerException; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Map; /** * A custom row-reader, designed to avoid an error on MSSql which is explained here : * * http://support.microsoft.com/default.aspx?kbid=824106 * <p/> * * Basically, this specialty class ensures we only read the resultset's columns ONCE. * * techframework.persistence.HPDRowReader, created on 06-Aug-2004 10:44:10 <p> * @author Charles */ public class HPDRowReader extends RowReaderDefaultImpl { ClassDescriptor cld; public HPDRowReader(ClassDescriptor cld) { super(cld); this.cld = cld; } public void readPkValuesFrom(ResultSet rs, Map row) { // Change from parent class : We read everything into the row, not just the PrimaryKeys 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++) { // Change from parent class - only read the column if the row map does not contain // a value for the column - in other workds, avoid reading the column twice fld = fields[i]; String columnName = fld.getColumnName(); if (!row.containsKey(columnName)) { val = fld.getJdbcType().getObjectFromColumn(rs, columnName); row.put(columnName, fld.getFieldConversion().sqlToJava(val)); } } } catch (SQLException t) { throw new PersistenceBrokerException("Error reading class type: " + cld.getClassNameOfObject() + " from result set, current read field was " + (fld != null ? fld.getPersistentField().getName() : null), t); } } } > -----Original Message----- > From: Sebastian [mailto:[EMAIL PROTECTED] > Sent: 29 September 2004 11:35 > To: [EMAIL PROTECTED] > Subject: Problem when moving from 1.0.0 to 1.0.1 > > > When updating OJB my app throws the exception below. The db > server is MS > SQL. I found one technote regarding this issue but don't know what to > change in OJB: http://support.microsoft.com/default.aspx?kbid=824106 > > Thanks for any hints in advance. > > org.apache.ojb.broker.PersistenceBrokerException: Error reading class > type: mappedObjects.User from result set, current read field was > secondary_calendar_preference > at > org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.readVal > uesFrom(Unknown > Source) > at > org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.readObj > ectArrayFrom(Unknown > Source) > at > org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResu > ltSet(Unknown > Source) > at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown > Source) > at > org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionB > yQuery(Unknown > Source) > at > org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionB > yQuery(Unknown > Source) > at > org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionB > yQuery(Unknown > Source) > at > org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollection > ByQuery(Unknown > Source) > at > org.apache.ojb.broker.core.DelegatingPersistenceBroker.getColl > ectionByQuery(Unknown > Source) > at > org.apache.ojb.broker.core.DelegatingPersistenceBroker.getColl > ectionByQuery(Unknown > Source) > at Export.main(Export.java:36) > Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 > Driver for > JDBC]ResultSet can not re-read row data for colu > mn 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(Unkn > own Source) > at > com.microsoft.jdbc.base.BaseResultSet.getString(Unknown Source) > at > com.microsoft.jdbc.base.BaseResultSet.getString(Unknown Source) > at > org.apache.ojb.broker.util.JdbcTypesHelper$T_Varchar.readValue > FromResultSet(Unknown > Source) > at > org.apache.ojb.broker.util.JdbcTypesHelper$BaseType.getObjectF > romColumn(Unknown > Source) > at > org.apache.ojb.broker.util.JdbcTypesHelper$BaseType.getObjectF > romColumn(Unknown > Source) > ... 15 more > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > ___________________________________________________________ HPD Software Ltd. - Helping Business Finance Business Email terms and conditions: www.hpdsoftware.com/disclaimer --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
