[OJB-developers] bug in PersistenceBrokerImpl?
Brought to you by:
thma
From: Georg S. <ge...@me...> - 2002-03-06 15:57:28
|
Hi, When executing an OQLQuery that searches for an interface instead of a concrete class (e.g. "select seqs from Sequence where ..." , where Sequence is an interface) and there is no matching result in the database a null-value is returned by broker.getCollectionByQuery... in OQLQueryImpl.java, this results in a NullPointerException a few lines later when trying to get the Iterator (result.ojbIterator()). ManageableCollection result = (ManageableCollection) broker.getCollectionByQuery(this.getCollectionClass(), query); broker.commitTransaction(); // read-lock all resulting objects to the current transaction Iterator iter = result.ojbIterator(); The actual fault seems to lie in PersistenceBrokerImpl in public ManageableCollection getCollectionByQuery(Class collectionClass, Query query, boolean lazy) throws PersistenceBrokerException { where ManageableCollection result = null; is set at the beginning of the method, but if there is no match in the database and the query was for an interface, execution falls through until the last statement return result; which simply returns null I added the following lines just before the return statement and everything works fine, but since I haven't familiarised myself too much with the code, I don't know if this would have other effects somewhere else. if (result == null) { try { result = (ManageableCollection) collectionClass.newInstance(); } catch (Throwable t) { throw new PersistenceBrokerException(t); } } I have another problem, which is giving me a headache. I am developing on a UNIX system and whenever I execute build.sh the preprocessor somehow converts the files to contain CRLFs again. How can I turn this off? Regards Georg |