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 "Sean P. Hawkins" <sp...@steelpagoda.com> on 2003/12/03 18:50:42 UTC
Joined table query question
Greetings all,
I am attempting to get a simple inheritance structure working under OJB
1.0rc4 running under Jboss with postgres. Here's the background:
Repository.xml fragment:
<class-descriptor
class="com.steelpagoda.fist.model.PersonImpl"
table="people"
>
<!--
<extent-class class-ref="com.steelpagoda.fist.model.StudentImpl" />
-->
<field-descriptor
name="id"
column="pid"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"
/>
<field-descriptor
name="lastName"
column="lastname"
jdbc-type="VARCHAR"
/>
..snip..
</class-descriptor>
<class-descriptor
class="com.steelpagoda.fist.model.StudentImpl"
table="students"
>
<reference-descriptor name="super"
class-ref="com.steelpagoda.fist.model.PersonImpl">
<foreignkey field-ref="id" />
</reference-descriptor>
<field-descriptor
name="id"
column="pid"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="false"
/>
<field-descriptor
name="foo"
column="foo"
jdbc-type="VARCHAR"
/>
</class-descriptor>
Query code:
Criteria crit = new Criteria();
crit.addLike("upper(lastName)", "%" + searchString.toUpperCase()
+ "%");
Transaction tx = odmg.currentTransaction();
PersistenceBroker pb = ((NarrowTransaction) tx).getBroker();
QueryByCriteria q = QueryFactory.newQuery(PersonImpl.class,
crit, false);
Collection retVal = pb.getCollectionByQuery(q);
Here's what I'm getting:
- This works fine as listed.
- If I query against a field in StudentImpl ("foo"), it returns me
full-fledged studentImpl objects with the appropriate inherited fields
populated (working as expected.)
- If I uncomment the extent-class in PersonImpl, I get a sql error
stating lastname is not an attribute. (broken)
- If I try to query against StudentImpl as follows:
crit.addLike("upper(super.lastName)", "%" +
searchString.toUpperCase() + "%");
....
QueryByCriteria q = QueryFactory.newQuery(StudentImpl.class,
crit, false);
I get a "relation super does not exist" error (broken)
The same behavior is exhibited by the ODMG query interface (as I would
expect.)
Any ideas? Sorry if this is a stupid user error.
--Sean
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org