• 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: D2W EditToOne relationship question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: D2W EditToOne relationship question


  • Subject: Re: D2W EditToOne relationship question
  • From: Aaron Rosenzweig <email@hidden>
  • Date: Wed, 9 Mar 2005 22:08:00 -0500

Thank you Chuck, Anjo, and others who read my post,

I've put a contrived example together which can downloaded from here:

http://www.cocoanutstech.com/files/toOneRelationshipTest.eomodeld.zip

At first I thought I was doing something to goof up the works. That perhaps my code had some side effect on the EditingContext. But, after building very simple contrived example, I realize that I did nothing wrong.

That zip file contains a single EOmodel file. With it, you can create a straightforward D2W project. It contains two tables: PERSON and BIOGRAPHY.

To see the problem, launch and build the D2W project and then:

1) create a new person
2) be sure to create a new biography
3) save the biography
4) save the person.
5) search for the person you created
6) edit the person you created.
7) edit the biography relationship
8) save the new biography relationship
9) *attempt* to save the person - it will give you a NULL error.

Seriously friends, vanilla D2W does not handle this case. I'm 99% sure that the EOmodel is set up correctly and I've done nothing wrong. But please correct me if I've made an oversight.

My next step is to freeze the component and see if I can manually add a new biography relationship by explicitly calling "addToBothSidesOfRelationshipWithKey." Wish me luck :-) Any and all advice is appreciated.

Thanks in advance,
-- Aaron
Author of the "Old Fart's Guide" series
http://www.cocoanutstech.com/

On Mar 8, 2005, at 1:06 PM, Chuck Hill wrote:

Problems arise when I try to edit an existing "Merchandise" instance and update it with a new "Thumbnail" instance. It can't be done! The framework keeps trying to save NULL for the primary key of the new Thumbnail instance and therefore rejects the request to save changes.

How are you doing this? It sounds like there are _two_ Thumbnail instances in the editing context. Try logging out ec.insertedObjects(), ec.updatedObjects(), and ec.deletedObjects(). In the case of owned relationships, EOF manages object creation for you. I suspect that you are duplicating its work somewhere.


Chuck

On Mar 7, 2005, at 8:41 PM, Aaron Rosenzweig wrote:

Hello Everyone,

=== Problem Description: ===
I want to connect two tables with a Mandatory and Owned To-One relationship where I propagate the primary key of the main table to the subordinate table. That's a mouthful! More concretely, I have a "Merchandise" table which contains information about price, shipping, title, summary, etc. I want to have a "Thumbnail" image of a particular merchandise but I don't want it stored as a column of the "Merchandise" table. I don't always need to show the Thumbnail in my application so I want to load that image "on demand" only when it is needed. This saves memory and traffic to the database. So… I set up "Merchandise" and "Thumbnail" in EOModeler like this:


"Merchandise":
1) Mandatory
2) Owns Destination
3) Propagate Primary Key
4) Cascades on delete

"Thumbnail":
1) Mandatory
2) nullifies on delete (I also tried the option to do nothing on delete).


This is exactly like the classic "Movies" EOModel file Apple ships as an example. They do the same thing with the "Talent" and "TalentPhoto" tables.


=== D2W Limitation Description: ===
Maybe I'm just overlooking something, but for the past 7 days I have been trying to get my basic D2W project to work. I can create a new "Merchandise" entity and a new "Thumbnail" image just fine. This saves to the database and works perfectly.


Problems arise when I try to edit an existing "Merchandise" instance and update it with a new "Thumbnail" instance. It can't be done! The framework keeps trying to save NULL for the primary key of the new Thumbnail instance and therefore rejects the request to save changes.


=== Shred of Hope ===
I really want to work "with" WebObjects, not against it because "it will win" - or so I've heard. I believe making custom "Property Level" components best leverages the dynamic nature of D2W. I don't want to freeze a page and do some clever hacking to try to get this case to work.


I started poking around in "Project WOnder" and found ERDEditOwnedRelationship and ERD2WTwoLevelEditToOneRelationship which might do what I want, but they seem quite complex and I don't understand the options that show up in the D2W configuration applet when I select these relationships.

Thanks in advance,
-- Aaron
Author of the "Old Fart's Guide" series
http://www.cocoanutstech.com/

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


This email sent to email@hidden


--
Practical WebObjects - a book for intermediate WebObjects developers who want to increase their overall knowledge of WebObjects, or those who are trying to solve specific application development problems.
http://www.global-village.net/products/practical_webobjects





_______________________________________________ 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: D2W EditToOne relationship question
      • From: Chuck Hill <email@hidden>
References: 
 >D2W EditToOne relationship question (From: Aaron Rosenzweig <email@hidden>)
 >Re: D2W EditToOne relationship question (From: Chuck Hill <email@hidden>)

  • Prev by Date: Stop Start Problem with Tomcat 5.0.28
  • Next by Date: can iText convert my HTML content to PDF ?
  • Previous by thread: Re: D2W EditToOne relationship question
  • Next by thread: Re: D2W EditToOne relationship question
  • Index(es):
    • Date
    • Thread