your mapping looks fine. I think your problem should be fixed in latest from CVS (Jakob committed a fix a few days ago).
(Side note: Be carefully when using anonymous key feature in other conjunction than 1:1 references, e.g for PK fields. It's only valid
if the persistent objects never be serialized or copied - more docs about that in next upcoming release).
regards, Armin
Charles N. Harvey III wrote:
Here is my repository.xml file with the following objects:
------------------------------------------------------------------------ <class-descriptor class="TheObject" table="THE_OBJECT"> <field-descriptor name="oid" column="OID" jdbc-type="INTEGER" primarykey="true" access="anonymous"/> <field-descriptor name="foreignId" column="foreign_id" jdbc-type="INTEGER" access="anonymous"/> <reference-descriptor name="foreignObject" class-ref="ForeignObject"> <foreignkey field-ref="foreignId"/> </reference-descriptor> </class-descriptor>
<class-descriptor
class="ForeignObject"
table="FOREIGN_OBJECT">
<field-descriptor
name="foreignId"
column="FOREIGN_ID"
jdbc-type="INTEGER"
primarykey="true"
access="anonymous"/>
<field-descriptor
name="otherStuff"
column="other_stuff"
jdbc-type="VARCHAR"
access="readwrite"/>
</class-descriptor>
<class-descriptor class="SubObject" table="SUB_OBJECT"> <field-descriptor name="oid" column="OID" jdbc-type="INTEGER" primarykey="true" access="anonymous"/> <reference-descriptor name="super" class-ref="TheObject" auto-retrieve="true" auto-update="true" auto-delete="true"> <foreignkey field-ref="oid"/> </reference-descriptor> <field-descriptor name="someString" column="some_string" jdbc-type="VARCHAR" access="readwrite"/> </class-descriptor> ------------------------------------------------------------------------
Again, any help is greatly appreciated. Thanks!
Charlie
Charles N. Harvey III wrote:
Ok. I've asked a few questions over the past week with no replies. Which
lead me to believe that I hadn't RTFM as thoroughly as I should have. This
proved to be correct. So I did more reading on the site and most of my
questions have been answered. But this time I swear I've read the entire site
and I'm just not sure how to do this.
I have 3 classes, TheObject, ForeignObject and SubObject.
public class TheObject { Integer oid; ForeignObject foreignObject; } public class ForeignObject { Integer foreignId; String otherStuff; } public class SubObject extends TheObject { Integer oid; String someString; }
I want to be able to query SubObject and get all the information for related
TheObjects and ForeignObjects.
This works: ------------------------------------------------------------------ Criteria crit = new Criteria(); crit.addEqualTo( "foreignObject.otherStuff", "blahBlah" ); Query q = QueryFactory.newQuery( TheObject.class, crit ); Collection tObjects = broker.getCollectionByQuery( q ); ------------------------------------------------------------------ Exactly what I wanted, within each TheObject in tObjects I can access ForeignObject by obj.getForeignObject().getOtherStuff().
Now, when I try to run the same query on SubObject, it fails. Somewhat
understandably because "foreignObject.otherStuff" is not mapped in SubObject.
------------------------------------------------------------------
Criteria crit = new Criteria();
crit.addEqualTo( "foreignObject.otherStuff", "blahBlah" );
Query q = QueryFactory.newQuery( SubObject.class, crit );
Collection sObjects = broker.getCollectionByQuery( q );
------------------------------------------------------------------
I thought that since SubObject extends TheObject that "foreignObject.otherStuff"
would be recognized. Its not. Is there some way to make this work?
I will continue to scour the site but if someone has already explained this before
please point me to the link.
Thanks a lot.
Charlie
--------------------------------------------------------------------- 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]
