Re: Tutorial Apache Cayenne Modeler 3.0 Many to Many Relationship

Andrus Adamchik <[email protected]> Sun, 16 Nov 2025 08:58:08 -0500
Newsgroups gmane.comp.java.cayenne.user
Message-ID <[email protected]>
Hi,

I am not aware of a dedicated tutorial (and it's been a while since 3.0, =
so I don't remember where we stood with the Modeler capabilities), but =
the general approach would be the same for any Cayenne version. Consider =
a "classic" many-to-many DB schema: two tables, and join table between =
them: A - AB - B:

1. Model DbEntities for all 3 of them
2. Model two pairs of bi-directional DbRelationships:

"abs" from A to AB ("To Many" and "To Dep PK" checked), "a" from AB to A =
("To One", "To Dep PK" not checked)
"abs" from B to AB ("To Many" and "To Dep PK" checked), "b" from AB to B =
("To One", "To Dep PK" not checked)

3. Model ObjEntities for A and B (but not for AB)
4. Create 2 "flattened" ObjRelationships:

"bs" from A to B, spanning two DbRelationships: "abs.b"
"as" from B to A, spanning two DbRelationships: "abs.a"

Hope this helps.

Andrus

> On Nov 13, 2025, at 10:41=E2=80=AFAM, Andre Gustavo Lomonaco =
<[email protected]> wrote:
>=20
> Hi.
>=20
> I am still using Cayenne Modeler 3.0 in my application and I need help
> if possible to find some good tutorial for creating Many to Many
> Relationship
> using Modeler 3.0.
>=20
> I found one-to-many but not many-to-many tutorials.
>=20
> If someone can indicate me a link I really will appreciate it
>=20
> Thanks a lot
>=20
> Andre Gustavo