On Nov 18, 2003, at 2:24 AM, Michael Schuldt wrote:
> Hi Andrus,
>
> after using the new cayenne.jar I'm now getting a "" error right at
> the same
> point:
>
> org.objectstyle.cayenne.CayenneRuntimeException: [v.1.0.x-dev November
> 17
> 2003] Cannot modify the read-only flattened relationship
> reaktiviertVonAlt
> at
> org.objectstyle.cayenne.CayenneDataObject.setToOneTarget(CayenneDataObj
> ect.j
> ava:345)
> at
> de.best4rest.boerse._TbAngebot.setReaktiviertVonAlt(_TbAngebot.java:
> 592)
Well this is the extra checks I was talking about. Currently Cayenne
can only support read-only flattened to-one. My testing shows that
while it may have *appeared* to work before as read-write, likely it
wasn't always doing the right thing. So I figured I'd make this
limitation more explicit.
> I've found a workaraound by using a ToMany-relationship instead of a
> ToOne.
> This will work but causes me much work in several other classes and
> JSPs.
This is a year old argument against to-one flattened writeable
relationships made by Craig Miskell:
http://www.objectstyle.org/cayenne/lists/cayenne-devel/2002/10/0017.html
Your case is different though, and there may not be any deep technical
reasons to disallow such relationship, and we can support such case in
theory. But I want to understand the reason behind such mapping.
"angebot_reaktivieren_assoz" table serves as a join in an optional
one-to-one reflexive relationship (in DB terms it is really
many-to-many... only the business logic assumes to-one):
<db-relationship name="fromReaktiviertAssozAls"
source="angebot_reaktivieren_assoz" target="tb_angebot"
toDependentPK="false" toMany="false">
<db-attribute-pair source="REAKTIVIERT_ALS" target="ID"/>
</db-relationship>
<db-relationship name="fromReaktiviertAssozVon"
source="angebot_reaktivieren_assoz" target="tb_angebot"
toDependentPK="false" toMany="false">
<db-attribute-pair source="REAKTIVIERT_VON" target="ID"/>
</db-relationship>
<db-relationship name="toReaktiviertAssozAls" source="tb_angebot"
target="angebot_reaktivieren_assoz" toDependentPK="true"
toMany="false">
<db-attribute-pair source="ID" target="REAKTIVIERT_ALS"/>
</db-relationship>
<db-relationship name="toReaktiviertAssozVon" source="tb_angebot"
target="angebot_reaktivieren_assoz" toDependentPK="true"
toMany="false">
<db-attribute-pair source="ID" target="REAKTIVIERT_VON"/>
</db-relationship>
So, it can be as easily mapped without the join table, just by adding a
reflexive FK to "tb_angebot". Of course I have no idea about your
business rules, and I realize that you may have a legacy schema and/or
few other reasons to have the mapping done like that. I am just trying
to analyze the best solution on the Cayenne side of things....
Andrus
This archive was generated by hypermail 2.0.0 : Tue Nov 18 2003 - 22:54:12 EST