I haven't looked at the source of OJB for quite a while; and then it wan't in any depth.

I'd suggest you double-check the mappings in your repository.xml; I think you might have a typo, or mismatch... I believe the xml for what you're mapping should look something like:

<class-descriptor

       class="com.x.y.TestStep"

       table="TestStep">

       <field-descriptor

           name="id"

           column="id"

           jdbc-type="BIGINT"

           primarykey="true"

           autoincrement="true"/>

       <field-descriptor

           name="testRunId"

           column="testRunId"

           jdbc-type="BIGINT"

           access="anonymous"/>

       ....

       <reference-descriptor

           name="testRun"

           class-ref="com.x.y.TestRun"

           refresh="true"

           auto-retrieve="true"

           auto-update="true"

           auto-delete="false">

           <foreignkey field-ref="testRunId"/>

       </reference-descriptor>

   </class-descriptor>





   <class-descriptor

       class="com.x.y.TestRun"

       table="TestRun">

       <field-descriptor

           name="id"

           column="id"

           jdbc-type="BIGINT"

           primarykey="true"

           autoincrement="true"/>

       ...

   </class-descriptor>


While you would then need a TestStep class like:


   public class TestStep {

       private TestRun testRun = null;

       ....

   }


Aside from double checking these I can't think of anything. I have not had any trouble with this type of mapping.



Beeker, Andreas wrote:

Hi Robert,

that was my first bet too, but in the StatementManager it will
simply try to bind the TestRun-instance onto the parameter instead
of binding the anonymous key.
I rechecked my repository, but it seems to be ok.

Any ideas?

Thanks,
Andreas.




Robert r. Sanders wrote:

If your TestStep object has a field testRun then the query should only need to:

TestRun myTestRun = ...;
Criteria criteria = new Criteria();
criteria.addEqualTo("testRun", myTestRun);
....
OJB will take care of all the identity lookups for you (as long as the configuration xml is correct).



Beeker, Andreas wrote:



Hi all,

I retrieved an object (class TestRun) by an existing Iterator-Query.
Now I want to find all objects of class TestStep which reference
the former TestRun-object. My primary keys are all anonymous keys and
also the foreign key of class TestStep (attribute "testRun"/
anonymous key "testRunId").

I've managed to find the right objects by this criteria:
TestRun run = ...;
Criteria crit = new Criteria();
crit.addEqualTo("testRun", new Identity(run,
broker).getPrimaryKeyValues()[0]);

I've also tried to use a subquery, which lead to an

ClassCastException


in SqlQueryStatement, because it assumes to get a QueryByCriteria:
crit.addIn("testRun", new QueryByIdentity(run));

My OJB version is 1.0.1 and I only use the PB-API. I've seen

that there


was a PB-extension for JDO (Criteria.addIdentityEqualTo) which could
solve
the problem.
Is this the right way or is there another more convienent


way to define


the criteria (... without knowing how many keys must be specified)?

Thanks,
Andreas.

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





--
   Robert r. Sanders
   Chief Technologist
   iPOV
   www.ipov.net


--------------------------------------------------------------------- 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]




-- Robert r. Sanders Chief Technologist iPOV www.ipov.net


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



Reply via email to