You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by Axel Hohaus <ax...@armax.de> on 2004/03/08 15:41:00 UTC

Unique key constraint violations with M-to-N Mapping

Hi all,

we have problems saving m:n relations. We get constraint violations.
Have a look at ojb-user list entry written by Peter Wieland.
I've changed code in the method storeCollectionObject of
PersistenceBrokerImpl. Now it works fine.
There is a comment describing problems with FK violation using m:n
relations with autoupdate. I think this problem exists without
autoupdate too.

Please have a look at my changes and check it in the cvs head, if it is
a bug. I used the method getMtoNImplementor outside the if
(cds.getCascadeStore()) statement.

        if (cds.isMtoNRelation())
        {
            if (cds.getCascadeStore())
            {
                // 1. Store depended upon object first to avoid FK
violation
                store(otherObj);
            }
             // BRJ: store could have inserted MtoNImplementors
             // so we need to read them to avoid ref. integrity
             // violations
             currentMtoNKeys = mtoNBroker.getMtoNImplementor(cds, obj);

            // 2. Store indirection record
            // BRJ: this could cause integrity problems because
            // obj may not be stored depending on auto-update
            mtoNBroker.storeMtoNImplementor(cds, obj, otherObj,
currentMtoNKeys);
        }

Regards

Axel

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org