• 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
Re: Bi-directional One-to-one relationship
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bi-directional One-to-one relationship


  • Subject: Re: Bi-directional One-to-one relationship
  • From: Des Oates <email@hidden>
  • Date: Sat, 16 Apr 2005 15:14:03 +0100

OK Sorry for not being clear, Here's an example.

I created 2 new EOs in a fresh EO model. DataEntity, and StateEntity.

In each a put a couple of Attributes and integer primary keys, PKData, and PKState respectively

To create a relationship I first copy PKState attribute, and paste it into DataEntity. I then cntr + drag from StateEntity.PKState to DataEntity.PKState.

By default that creates a One-to-many relationship. It inserts the relationship properties 'stateentity' and 'dataentitys' into DataEntity and StateEntity respectively.

I want to change this so I highlight StateEntity.dataentitys and open my inspector. I change the 'To Many' property to 'To One' in the relationship's inspector.

I also set its optionality to 'Mandatory' and its delete rule to no action.
On the other side of the relation ship (DataEntity.stateentity) I also set the optionality to Mandatory, set the delete rule to 'cascade' and the tick the 'owns destination'

If at this point I want to check the consistency of the model. I go to the Model Menu, and hit the 'Check Consistency' menu. This reports the following problem:

Relationship dataentitys in entity StateEntity is a to-one relationship, but its destination attribute(s) does not match the primary key of the destination entity.

Is this something I can live with? I don't believe so, since later on I get runtime errors when these objects are created relating to null primary keys, OR duplicate primary keys being created. I also get runtime errors if I create 2 independent and opposing unidirectional to-one relationships.

The only way I can get a one-to-one relationship to work is if I delete the relationship on the destination, which in this case would be 'StateEntity.dataentitys'. Then it works but of course its now unidirectional. I.e. I can't navigate to my DataEntity from my StateEntity. I want to be able to navigate to and from either object.

Sorry for being long winded, but that's about as concise as I could make it.

Des



On 16 Apr 2005, at 13:07, Drew Thoeni wrote:

If you are talking about setting up a o-o relationship, then yes EOmodeler will do this. Create the two tables, ctrl-drag from the primary key in one to the PK in the other and in the resulting window, click "to one".

I suspect you are, though, asking a more complex question. If you are, perhaps you can clarify with an example.

Drew

On Apr 16, 2005, at 8:01 AM, Des Oates wrote:

Does anyone know if EO Modeler supports a one-to one relationship where each related object is referenced as a property in the other? I've been trying to set up my EOModel like this for a while now, but no matter which way I try to do it EO Modeler complains.

A use case of this would be if you have a single data object, linked to its corresponding single state object. In O-O you would want to keep the logic handling these separate. (I.e. 2 different classes)

I ended up working around this so its not a showstopper for me but I'm just curious for future reference if anyone's actually managed to do it, and if so how.

thanks
Des

_______________________________________________
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


 _______________________________________________
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: Bi-directional One-to-one relationship
      • From: Drew Thoeni <email@hidden>
References: 
 >Bi-directional One-to-one relationship (From: Des Oates <email@hidden>)
 >Re: Bi-directional One-to-one relationship (From: Drew Thoeni <email@hidden>)

  • Prev by Date: Re: 10.3.9 Update-Java crash
  • Next by Date: Re: Tiger?
  • Previous by thread: Re: Bi-directional One-to-one relationship
  • Next by thread: Re: Bi-directional One-to-one relationship
  • Index(es):
    • Date
    • Thread