I have auto-retreive set to false in all my descriptors currently. Reason I do that is because sometimes I am not interested in getting the related objects, I just want to do a select from the table and just get the data back.

However, there are times when I do want to fetch the related objects. So with that, I tried the following code below, but it seems that it's incorrect since my bean still returns a null for the related bean.

final Query query = QueryFactory.newQuery( Category.class, crit );
broker.beginTransaction();
final ObjectReferenceDescriptor ord = new ObjectReferenceDescriptor( broker.getClassDescriptor( Project.class ) );
ord.setCascadeRetrieve( true );
final List results = ( List ) broker.getCollectionByQuery( query );
broker.commitTransaction();


I have a foreign key relationship between Category and Project. I was to select categories in this case and also get the Project objects back with it. Project and Category are Interfaces.


<class-descriptor class="com.codepuccino.tracker.beans.Category">
<extent-class class-ref="com.codepuccino.tracker.beans.ojb.CategoryBean"/>
</class-descriptor>
<class-descriptor class="com.codepuccino.tracker.beans.ojb.CategoryBean" table="CDPCNO_CATEGORIES">
<field-descriptor name="ID" nullable="false" column="category_id" jdbc-type="INTEGER" primarykey="true" autoincrement="true"/>
<field-descriptor name="name" nullable="false" column="category_name" jdbc-type="VARCHAR" primarykey="false"/>
<field-descriptor name="orderID" nullable="true" column="category_order" jdbc-type="INTEGER" primarykey="false"/>
<field-descriptor name="projectID" nullable="false" column="project_id" jdbc-type="INTEGER" primarykey="false"/>
<reference-descriptor name="projectBean" class-ref="com.codepuccino.tracker.beans.Project" auto-retrieve="false" auto-update="false" auto-delete="false" refresh="true">
<foreignkey field-ref="projectID"/><!-- the reference from THIS table to the project table! -->
</reference-descriptor>
</class-descriptor>



Thanks


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



Reply via email to