• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
addObjectsToBothSide... not really both side
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

addObjectsToBothSide... not really both side


  • Subject: addObjectsToBothSide... not really both side
  • From: Dev WO <email@hidden>
  • Date: Mon, 25 Sep 2006 19:26:30 +0200

Hi:)
I've got a couple question for the next hours as I was "storing" them to find the answer by myself, but I couldn't resolve a couple of them.

So this one is a oneToOne relationship, with is specified in both entities A and B.

But when I call both addObjectsToBothSide... only A gets updated...

Here's my code:

//I'm created the relationship when I create and insert A into the ec
public EOGenericRecord object() {
if (object == null) {
object = (A)EOUtilities.createAndInsertInstance(ec, "A");
((A)object).setARelationship(b());
}
return object;
}

//This is called when B is requested
public B b() {
if (b == null) {
b = (B)EOUtilities.createAndInsertInstance(ec, "B");
}
return b;
}

// calling saveChanges() later

//In my framework, here's what I have for setARelationship
    public void setARelationship(B aValue) {
        if( log.isDebugEnabled() ) log.debug( "updating b from "+b()+" to "+aValue );
        if( aValue == null ) {
            B object = b();
            if( object != null )
                removeObjectFromBothSidesOfRelationshipWithKey( object, "b" );
        } else
            addObjectToBothSidesOfRelationshipWithKey( aValue, "b" );
    }



A and B have a foreign key to each other, but only A gets it... B's foreign key stay "null".

Anyone see what I'm doing wrong?

Thanks:)

Xavier
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: addObjectsToBothSide... not really both side
      • From: Zak Burke <email@hidden>
    • newbie question
      • From: <email@hidden>
  • Prev by Date: Re: Who's got the <button>?
  • Next by Date: newbie question
  • Previous by thread: Re: WOUnit and EOEditingContext not found
  • Next by thread: newbie question
  • Index(es):
    • Date
    • Thread