db-ojb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Armin Waibel <arm...@apache.org>
Subject Re: SqlQueryStatement.splitCriteria -> NullPointerException
Date Sat, 21 Aug 2004 10:21:23 GMT
Hi Jakob, Joshua,

made a test with a modified version of QueryTest#testReportQueryExtent 
against AbstractArticle.class. This test pass. Maybe BaseInterface.class 
  did not declare extents in repository?

regards,
Armin

J.Braeuchi wrote:
> hi joshua,
> 
> what version of ojb are you using ?
> is it ok to use hashcode 0 if no table is available.
> 
> jakob
> 
> Phillips, Joshua (NIH/NCI) schrieb:
> 
>> The collection-descriptor for an abstract class does not have a table
>> attribute. So, when SqlQueryStatement.splitCriteria is called, a
>> NullPointerException is thrown when it tries to put the root 
>> TableAlias into
>> the m_jointTreeToCriteria HashMap, because
>> SqlQueryStatement.TableAlias.hashCode looks like this:
>>
>>         public int hashCode() {
>>             return table.hashCode();
>>         }
>>
>> ...and table is null.
>>
>> The code that I used to produce this error looks like this:
>>
>> PersistenceBroker pb = PersistenceBrokerFactory
>>     .defaultPersistenceBroker();
>> Criteria subCrit = new Criteria();
>> subCrit.addEqualTo("id", new Long(1));
>> ReportQueryByCriteria assocPBQ = QueryFactory.newReportQuery(
>>     BaseInterface.class, subCrit);
>> assocPBQ.setAttributes(new String[] { "id" });
>> Criteria crit = new Criteria();
>> crit.addIn("base.id", assocPBQ);
>> QueryByCriteria q = (QueryByCriteria) QueryFactory.newQuery(
>>     BaseAssocInterface.class, crit, true);
>> Collection c = pb.getCollectionByQuery(q);
>>
>> The stack trace looks like this:
>>
>> Caused by: java.lang.NullPointerException
>>     at
>> org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias.hashCode( 
>>
>> Unknown Source)
>>     at java.util.HashMap.hash(HashMap.java:261)
>>     at java.util.HashMap.put(HashMap.java:379)
>>     at
>> org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.splitCriteria(Unknow 
>>
>> n Source)
>>     at
>> org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.<init>(Unknown
>> Source)
>>     at
>> org.apache.ojb.broker.accesslayer.sql.SqlSelectStatement.<init>(Unknown
>> Source)
>>     at
>> org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.getSubQuerySQL(Unkno 
>>
>> wn Source)
>>     at
>> org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendSubQuery(Unkno 
>>
>> wn Source)
>>     at
>> org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendParameter(Unkn 
>>
>> own Source)
>>     at
>> org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendInCriteria(Unk 
>>
>> nown Source)
>>     at
>> org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendCriteria(Unkno 
>>
>> wn Source)
>>     at
>> org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendSQLClause(Unkn 
>>
>> own Source)
>>     at
>> org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.asSQLStatement(Unkno 
>>
>> wn Source)
>>     at
>> org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendClause(Unknown 
>>
>> Source)
>>     at
>> org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendWhereClause(Un 
>>
>> known Source)
>>     at
>> org.apache.ojb.broker.accesslayer.sql.SqlSelectStatement.getStatement(Unknow 
>>
>> n Source)
>>     at
>> org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl.getPreparedSel 
>>
>> ectStatement(Unknown Source)
>>     at
>> org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeQuery(Unknown
>> Source)
>>     at
>> org.apache.ojb.broker.accesslayer.RsQueryObject.performQuery(Unknown 
>> Source)
>>     at org.apache.ojb.broker.accesslayer.RsIterator.<init>(Unknown
>> Source)
>>     at
>> org.apache.ojb.broker.core.RsIteratorFactoryImpl.createRsIterator(Unknown
>> Source)
>>     at
>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getRsIteratorFromQuery(Unkn 
>>
>> own Source)
>>     at
>> org.apache.ojb.broker.core.PersistenceBrokerImpl.getIteratorFromQuery(Unknow 
>>
>> n Source)
>>     at
>> org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown 
>>
>> Source)
>>     ... 20 more
>>
>> Joshua Phillips
>> Contractor (SAIC)
>> Tel: 301 451 6346
>> Fax: 301 480 4222
>> phillijo@mail.nih.gov
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>  
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Mime
View raw message