Hm.

Never tried it, but, could you define two /obj/ relationships?
One flattened and one not?

Robert

On Mar 17, 2009, at 3/174:16 PM , Mike Kienenberger wrote:

Yes, but as far as I know, Dan cannot flatten the relationship list
without losing access to the other information contained in the join
table.

I have had the same issue, and as far as I know, you have to live
without flattened relationships in this case.

On Tue, Mar 17, 2009 at 2:34 PM, Andrey Razumovsky
<[email protected]> wrote:
Dan,

As far as I know, Cayenne *should* allow that prefetch and there should be less than N+1 select. Is there any exception now? You'd likely want to check prefetch docs [1] to see that your query isn't under limitation described
there.

About flattened relationships, these ones only affect object layer, not database layer. So all DB structure will remain untouched. Have a look at many-to-many modeling article [2]! It's a bit out of date (ObjRelationship mapping dialog has changed recently and became more user-friendly), but
you'll get the point!

Andrey

[1] http://cayenne.apache.org/doc/prefetching.html
[2] http://cayenne.apache.org/doc/many-to-many-relationships.html

2009/3/17 Dan <[email protected]>

Andrey Razumovsky <razumovsky.andrey <at> gmail.com> writes:


Hi Dan!

It seems quite strange to me that relationship from PARTY_CASE_LINK to
PARTY
is called "parties". So seems it's to-many. But PARTY_CASE_LINK has
"partyid", so no more than one PARTY can exist for PARTY_CASE_LINK.
Also can't flattened relationships [1] be useful for you in this case?

[1] http://cayenne.apache.org/doc/flattened-relationships.html

Andrey


Andrey,

Ahh - yes - there was a flaw in the data model - the relationships to the
PARTY_CASE_LINK table should be toMany, but all of the reverse
relationships
should be toOne.

So i now have relationships that allow me to get

List<PartyCaseLink> casesLinks = pty.getPartyCases();
for (PartyCaseLink caseLink : casesLinks)
{
    CourtCase cases = caseLink.getCase();
    ... do stuff
}

That is now resolved, and I can get "half" way to the objects that I want
without additional DB queries using:

selectQuery.addPrefetch("partyCases");

BUT -- i see that cayenne is not allowing me to addPrefetch all the way to
the
"case" -- e.g. i want to:

selectQuery.addPrefetch("partyCases.case");

to avoid going back to the database N times (1 per row).

...

Also - flattened relationships look interesting, but since I have a "real" relationship in the database there already, shouldn't i be able to use
that?

Thanks again in advance.

dan




Reply via email to