• 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: help with a relationship...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: help with a relationship...


  • Subject: Re: help with a relationship...
  • From: Theodore Petrosky <email@hidden>
  • Date: Wed, 6 May 2009 11:04:24 -0700 (PDT)

the problem is that:

I hope that above all, the tone that I want to express is one of gratitude and awe that you guys have this knowledge at your finger tips, and are willing to share it.

1. I am inexperienced
2. I feel that I work in a Vacuum and being inexperienced I think I am heading to perdition (or at least feeling alone)
3. At times I hesitate to ask because the answers are sometime over my head...
4. as for the naming..... I need to learn a lot.... and this project has morphed from a simple contact manager to a lot more.

BTW what would you have called the contactEO?

John's answer below is the exception.... I still don't understand WHY this works, but at least I can continue and hopefully learn a little.

Being a beginner, the instructions "look for the small diamond in Entity Modeler" made the difference....

+++++

Make sure that SubCategoryID isn't a class property (that there is not
a small diamond next to it in Entity Modeler).

John

++++++

--- On Wed, 5/6/09, Chuck Hill <email@hidden> wrote:

> From: Chuck Hill <email@hidden>
> Subject: Re: help with a relationship...
> To: "Theodore Petrosky" <email@hidden>
> Cc: email@hidden
> Date: Wednesday, May 6, 2009, 1:42 PM
>
> On May 6, 2009, at 10:38 AM, Theodore Petrosky wrote:
>
> >
> > I initialize contactEO in the constructor like this.
> >
> > contactEO = ERXEC.newEditingContext();
>
> It will be a LOT less confusing in the future if you give
> it a name 
> closer to what it actually is....
>
>
> >
> >
> > Ted
> >
> > --- On Wed, 5/6/09, Chuck Hill <email@hidden>
> wrote:
> >
> >> From: Chuck Hill <email@hidden>
> >> Subject: Re: help with a relationship...
> >> To: "Theodore Petrosky" <email@hidden>
> >> Cc: email@hidden
> >> Date: Wednesday, May 6, 2009, 12:47 PM
> >>
> >> On May 6, 2009, at 8:08 AM, Theodore Petrosky
> wrote:
> >>
> >>>
> >>> I have an object -- Contact -- the has a
> relationship
> >> to a Category.
> >>>
> >>> each contact one category. when I create a
> new
> >> contact, I read the categories from the backend
> and apply
> >> the first (zeroth) category (my generic category)
> >>>
> >>>     public void
> createNewContact() {
> >>>
> >> NSLog.out.appendln("top of createNewContact
> >> +++++++++++++++++++++++++++++");
> >>>
> >>>     
>    newContact = new
> >> Contact();
> >> Unrelated, but that line above is not needed with
> the next
> >> line:
> >>>
> >>>     
>    newContact =
> >>
> (Contact)EOUtilities.createAndInsertInstance(contactEO,
> >> "Contact");
> >>
> >> contactEO is an EditingContext, not an EO, right?
> >>
> >>
> >>>
> >>>
> >>>
> >>
> newContact.setContactCategory(contactCategoryList.objectAtIndex(0));
> >>>
> >> NSLog.out.appendln("newContact.setSubCategory+++ =
> " +
> >> newContact.subCategory());
> >>>
> >> newContact.setUser(repList.objectAtIndex(0));
> >>>     }
> >>>
> >>> This works beautifully. I get a new contact.
> If I
> >> actually type something in the contact name field
> and
> >> saveChanges() to the EO everything is 
> happy.
> >>>
> >>> well they want to add subCategories. I create
> the
> >> entity and have a relationship between subCategory
> and
> >> Contacts as well as subCategory and Category.
> >>>
> >>> each contact one subCategory
> >>> each Category one subCategory
> >>>
> >>> but obviously each Category many subCategories
> (same
> >> for Contacts).
> >>>
> >>> I can not seem to get the relation to work
> with the
> >> subCategory... I need to create a new contact so I
> add a
> >> line to the createNewContact:
> >>>
> >>>
> >>
> newContact.setSubCategory(subCategoryList.objectAtIndex(0));
> >>>
> >>> obviously subCategoryList is an array of
> subCategories
> >> that I read in exactly the same as the
> categoryList.
> >>>
> >>> so when I try to save the EO I get an error:
> >>>
> >>> - ValidationException e = Please provide a
> >> <b>Sub CategoryID</b>.
> >>>
> >>> So I added some NSLogs around the
> saveChanges() and I
> >> see:
> >>>
> >>> NSLog.out.appendln("inside try
> >> newContact.subCategory+++ = " +
> newContact.subCategory());
> >>> contactEO.saveChanges();
> >>>
> >>> if I read this correctly, the newContact has
> a
> >> subCategory with a primary key "1", but I still
> get this:
> >>>
> >>> - ValidationException e = Please provide a
> >> <b>Sub CategoryID</b>.
> >>>
> >>> I am at a loss.... I have added so many NSLogs
> to try
> >> to see the flow and it 'should' work... (I think)
> but I hate
> >> shoulding on myself....
> >>>
> >>> Ted
> >>>
> >>>
>



 _______________________________________________
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: help with a relationship...
      • From: Guido Neitzer <email@hidden>
    • Re: help with a relationship...
      • From: Chuck Hill <email@hidden>
  • Prev by Date: Re: Making the EOModel to work with LDAP
  • Next by Date: Re: help with a relationship...
  • Previous by thread: Re: help with a relationship...
  • Next by thread: Re: help with a relationship...
  • Index(es):
    • Date
    • Thread