0

We are using Cayenne with something like

    ResultIterator<SomeMain> lvSomeMainList = ObjectSelect
                               .query(Anlstamm.class)
                               .and(SomeMain.ORGUNIT_NR.eq(pvOrgUnitNr))
                               .prefetch(SomeMain.RELATION1.joint())
                               .prefetch(SomeMain.RELATION2.joint())
                               .prefetch(SomeMain.RELATION3.joint())
                               .iterator(gvContext);
 

    for (SomeMain bvSomeMain: lvSomeMainList) {

                           bvSomeMain.getMethod_relation1();
                            ...
    }

Cayenne executes the correct joins on DB-Level but instead of fully resolve bvSomeMain, getMethod_relation1 triggers a new select with the already prefetched RELATION1.

We are using Apache Cayenne 4.0

Thanks for a hint.

  • Nothing immediately obvious here (prefetches work rather reliably). Any warnings in the Modeler ? Could you maybe post the mapping details for the source and target entity of this relationship. Also is this the problem with one specific relationship or all 3 of them? – andrus_a Oct 23 '20 at 11:15
  • Also, if it's a large fetch, it's possible the fetched objects are being evacuated from the snapshot cache quite early (in which case you might want to up the snapshot cache size). – Hugi Oct 23 '20 at 16:22

0 Answers0