Hi Jakob,

I'm using 1.0.rc7.

Fixing the hashCode method doesn't solve the problem, unfortunately. The
problem is that the 'table' member of SqlQuery.TableAlias doesn't get
populated. So, NullPointerExceptions would occur in other places such as
appendTableWithJoins and getColName.

I don't really understand OJB's whole SQL generation flow yet, so I can't
completely diagnose the problem. But, I've found that the problem is fixed
by navigating down the extents until you find a table name, and then just
using this name instead. Of course, one has to make sure that the classes in
the extent of the abstract class do indeed map to one table.

I'll put together a test case demonstrating the problem (and hopefully a
solution) as soon as I get some time.

Thanks for your response.

Joshua Phillips
Contractor (SAIC)
Tel: 301 451 6346
Fax: 301 480 4222
[EMAIL PROTECTED] 

> -----Original Message-----
> From: J.Braeuchi [mailto:[EMAIL PROTECTED]
> Sent: Saturday, August 21, 2004 6:16 AM
> To: OJB Users List
> Subject: Re: SqlQueryStatement.splitCriteria -> NullPointerException
> 
> 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.hashCo
> de(
> >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(Unk
> now
> >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(Un
> kno
> >wn Source)
> >     at
> >org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendSubQuery(Un
> kno
> >wn Source)
> >     at
> >org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendParameter(U
> nkn
> >own Source)
> >     at
> >org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendInCriteria(
> Unk
> >nown Source)
> >     at
> >org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendCriteria(Un
> kno
> >wn Source)
> >     at
> >org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendSQLClause(U
> nkn
> >own Source)
> >     at
> >org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.asSQLStatement(Un
> kno
> >wn Source)
> >     at
> >org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendClause(Unkn
> own
> >Source)
> >     at
> >org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendWhereClause
> (Un
> >known Source)
> >     at
> >org.apache.ojb.broker.accesslayer.sql.SqlSelectStatement.getStatement(Unk
> now
> >n Source)
> >     at
> >org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl.getPrepared
> Sel
> >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(U
> nkn
> >own Source)
> >     at
> >org.apache.ojb.broker.core.PersistenceBrokerImpl.getIteratorFromQuery(Unk
> now
> >n Source)
> >     at
> >org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unkn
> own
> >Source)
> >     ... 20 more
> >
> >Joshua Phillips
> >Contractor (SAIC)
> >Tel: 301 451 6346
> >Fax: 301 480 4222
> >[EMAIL PROTECTED]
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to