db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Per-Olof Norén <pe...@alma.nu>
Subject NullPointer in SqlBasedRsIterator issue
Date Tue, 25 Feb 2003 16:09:54 GMT
Hi All,
I think a have found a bug in SqlBasedRsIterator

Scenario: Using fresch cvs checkout, SingleVM broker:

When calling:
String query = "select * from a_mapped_table where bla bla";
Collection collection = broker.getCollectionByQuery(query);
One gets:
java.lang.NullPointerException
    at 
org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResultSet(RsIterator.java:399)
    at 
org.apache.ojb.broker.accesslayer.SqlBasedRsIterator.getObjectFromResultSet(SqlBasedRsIterator.java:110)
    at 
org.apache.ojb.broker.accesslayer.RsIterator.next(RsIterator.java:235)
    at 
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(PersistenceBrokerImpl.java:1284)
    at 
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(PersistenceBrokerImpl.java:1410)
    at 
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(PersistenceBrokerImpl.java:1456)
    at 
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(PersistenceBrokerImpl.java:1443)
    at 
org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.getCollectionByQuery(DelegatingPersistenceBroker.java:310)

Which happens because SqlBasedRsIterator never explicitly calls the 
constructor of RsIterator and never assigns the protected cache member 
in rsIterator.
I have copied the snippet of code from RsIterator that assigns the cache 
and placed it in the constructor of SqlBasedRsIterator:
cache = broker.serviceObjectCache();

This solved seems to have solved the problem.
I can send a patch for this if it´s the correct way of solving the troubles.

ps
I recently sent another patch:
http://archives.apache.org/eyebrowse/ReadMsg?listName=ojb-dev@jakarta.apache.org&msgNo=3688
on which I haven´t got *any* input on, surely this project is accepting 
any help it can get?
ds

Regards,
Per-Olof Norén





Mime
View raw message