You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Bogdan Daniliuc <bd...@montran.ro> on 2004/03/26 17:12:45 UTC
NPE in TableAlias.hashCode
Hi all,
I'm running into a problem when using OJB rc5. I'm having a class hierarchy
with an abstract class A that holds, among others, a collection of class B
items and a collection of class A items. Class C extends class A. The
repository contains:
<class-descriptor class="A">
<extent-class class-ref="C"/>
</class-descriptor>
....
<class-descriptor class="C" table="C">
...
<field-descriptor
name="status"
column="STATUS"
jdbc-type="VARCHAR"
/>
...
<!-- A association (parts) -->
<collection-descriptor
name="parts"
proxy="true"
element-class-ref="A">
<inverse-foreignkey field-ref="parentId"/>
</collection-descriptor>
<!-- B association -->
<collection-descriptor
name="entries"
proxy="true"
element-class-ref="B">
<inverse-foreignkey field-ref="baseId"/>
</collection-descriptor>
</class-descriptor>
Class B has no references to other objects. I want to obtain all objects B
whose A correspondent have a certain status. Due to the potential of C
instances being too large, I'm trying to use a ReportQuery to run something like:
select * from B where baseId in (select id from A where status='XXX')
....
Criteria criteria1 = new Criteria();
criteria1.addEqualTo("status", "XXX");
ReportQueryByCriteria subQuery = new ReportQueryByCriteria(A.class,
new String[] { "id" },
criteria1);
Criteria criteria2 = new Criteria();
criteria2.addIn("baseId", subQuery);
QueryByCriteria query = new QueryByCriteria(B.class, criteria2);
Collection col = broker.findByQuery(query);
...
The above code results in a NPE in
org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias.hashCode.
The only solution I could find is to define a table in repository for class A.
Is this a bug or is the intended behaviour? It seems strange that the abstract
class should be mapped and the search is not done on the extents.
Regards,
Bogdan
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org