AW: [OJB-developers] ojb 7.325 QueryBySQL / SqlBasedRsIterator
Brought to you by:
thma
From: Mahler T. <tho...@it...> - 2002-02-05 07:41:34
|
Hi Jakob, > -----Urspr=FCngliche Nachricht----- > Von: Jakob Braeuchi [mailto:jbr...@ho...] > Gesendet: Montag, 4. Februar 2002 20:32 > An: obj...@li... > Betreff: [OJB-developers] ojb 7.325 QueryBySQL / SqlBasedRsIterator >=20 >=20 > hi, >=20 > when querying the db using queryBySql the sequence of the=20 > returned columns > is determined by the query not the columnNumber in the repository. >=20 > sql =3D "select * from tabPerson where name like '%er'"; > query =3D new QueryBySQL(Person.class, sql); >=20 > this can cause problems in JdbcAccess::GetObjectFromColumn. i=20 > suggest to use > the resultset to find the columnNumber by the columnName: >=20 > static Object getObjectFromColumn(ResultSet rs,=20 > FieldDescriptor fld) throws > SQLException > { > int jdbcType =3D getJdbcType(fld); > // int columnId =3D fld.getColNo(); > int columnId =3D rs.findColumn(fld.getColumnName()); =20 > //use columnId > from rs BRJ > return getObjectFromColumn(rs, jdbcType, columnId); > } >=20 > i have a question regarding=20 > SqlBasedRsIterator::getObjectFromResultSet() >=20 > protected Object getObjectFromResultSet() throws=20 > PersistenceBrokerException > { > // provide m_row with data of current row > m_mif.getRowReader().readObjectArrayFrom(m_rs, m_mif, m_row); > // assert: m_row is filled from db >=20 > ... >=20 > why do we need the call to readObjectArrayFrom() when super=20 > is called later > on, which will call readObjectArrayFrom() again ? >=20 I did not check the code. But if really works as you say it is = definitely a bug. readObjectArrayFrom() must only be called once for each ResultSet = row! -- Thomas > jakob >=20 > _______________________________________________ > Objectbridge-developers mailing list > Obj...@li... > https://lists.sourceforge.net/lists/listinfo/objectbridge-developers >=20 |