[OJB-developers] ojb 7.325 QueryBySQL / SqlBasedRsIterator
Brought to you by:
thma
From: Jakob B. <jbr...@ho...> - 2002-02-04 19:31:35
|
hi, when querying the db using queryBySql the sequence of the returned columns is determined by the query not the columnNumber in the repository. sql = "select * from tabPerson where name like '%er'"; query = new QueryBySQL(Person.class, sql); this can cause problems in JdbcAccess::GetObjectFromColumn. i suggest to use the resultset to find the columnNumber by the columnName: static Object getObjectFromColumn(ResultSet rs, FieldDescriptor fld) throws SQLException { int jdbcType = getJdbcType(fld); // int columnId = fld.getColNo(); int columnId = rs.findColumn(fld.getColumnName()); //use columnId from rs BRJ return getObjectFromColumn(rs, jdbcType, columnId); } i have a question regarding SqlBasedRsIterator::getObjectFromResultSet() protected Object getObjectFromResultSet() throws 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 ... why do we need the call to readObjectArrayFrom() when super is called later on, which will call readObjectArrayFrom() again ? jakob |