• 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: Automatically create record in a to-one relationship
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Automatically create record in a to-one relationship


  • Subject: Re: Automatically create record in a to-one relationship
  • From: Omar <email@hidden>
  • Date: Mon, 27 Jun 2005 19:47:25 -0400

Thanks for your answer Chuck & Art,

I checked the things you've sent me but I still can't get it to work.

This is the code I am using:

    public Application() {
        super();
        NSLog.out.appendln("Welcome to " + this.name() + " !");

                EOEnterpriseObject loRecord;
                EOEditingContext loEditingContext = new EOEditingContext();

ERXEC.factory().setDefaultDelegateOnEditingContext(loEditingContext);
                loEditingContext.lock();
                NSLog.out.appendln("1Registered Objects: " +
loEditingContext.registeredObjects());
                loRecord = (EOEnterpriseObject)
ERXEOControlUtilities.createAndInsertObject(loEditingContext, "table1");
                loRecord.takeValueForKey("data1a", "field1");
                loRecord.takeValueForKey("data1b", "field2");
                loRecord.takeValueForKey("data1c", "field3");
                loRecord.takeValueForKeyPath("Demo 2", "table2.myname");
                NSLog.out.appendln("2Registered Objects: " +
loEditingContext.registeredObjects());
                loEditingContext.unlock();
                loEditingContext.saveChanges();
                System.exit(0);
    }


I know this code doesn't really go here but I am just testing, I also
tried it in a more decent place and I get the same error.

The class name for both tables is EOGenericRecord so it can't be
awakeFromInsertion().

I also tried setting the relationship as mandatory and optional, same
result.

This is the output I get:


NSLog (ERXNSLogLog4jBridge.java:38)  - 1Registered Objects: ()
NSLog (ERXNSLogLog4jBridge.java:38)  - 2Registered Objects:
(<er.extensions.ERXGenericRecord pk:"null">)
NSLog (ERXNSLogLog4jBridge.java:41)  - A fatal exception occurred: A
<b>Table1</b> must have a <b>Table2</b>.

This is when I set the relationship to mandatory, from what I understand
though I should be able to use takeValueForKeyPath on table2 once I did
a createAndInsertObject on table1, maybe its doing it right and I am
just looking in the wrong place.

I am using WO 5.2.3 on Mac OS X 10.3.6 using PostgreSQL 8.0.1 if that
helps any.

Thanks again for your help,

Omar


Chuck Hill wrote:

> That is the right way to do it.  Check
> 1. You did this on the relationship from One to Two and not the other
> way around
> 2. You are calling ec.insertObject(one);
> 3. You have not overridden one.awakeFromInsertion() and forgotten to
> call super.awakeFromInsertion
>
>
> Chuck
>
> On Jun 24, 2005, at 1:23 PM, Omar wrote:
>
>> Hi all,
>>
>> I have the following problem, I have 2 tables with a to-one
>> relationship.
>>
>> I want WO to create a new row in table2 when I create a record in
>> table1, since they are in a to-one relationship.
>>
>> I was searching for this and found:
>>
>> http://www.wodeveloper.com/omniLists/webobjects-dev/2001/June/
>> msg01251.html
>>
>> I tried what it said but it didn't create the row in table2.
>>
>> Does anybody know how to do this?
>>
>> Thanks in advance,
>>
>> Omar
>>  _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list      (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>> 40global-village.net
>>
>> 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: Automatically create record in a to-one relationship
      • From: Art Isbell <email@hidden>
    • Re: Automatically create record in a to-one relationship
      • From: Nathan Walker <email@hidden>
References: 
 >Automatically create record in a to-one relationship (From: Omar <email@hidden>)
 >Re: Automatically create record in a to-one relationship (From: Chuck Hill <email@hidden>)

  • Prev by Date: Re: Deleting with Referential Integrities
  • Next by Date: Re: Application Configuration Strings
  • Previous by thread: Re: Automatically create record in a to-one relationship
  • Next by thread: Re: Automatically create record in a to-one relationship
  • Index(es):
    • Date
    • Thread