• 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 optional to-one relationship
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with optional to-one relationship


  • Subject: Re: Help with optional to-one relationship
  • From: Ken Anderson <email@hidden>
  • Date: Fri, 28 Aug 2009 00:01:24 -0400

This relationship is not guaranteed to be to-one, since there could be many States that match the Seo's ID.

The way I deal with this is to model it as a to-many relationship, and write methods in the EO that set/get, enforcing the to-one concept.


On Aug 27, 2009, at 10:28 PM, Amiel Montecillo wrote:

Hello,

I have a to-one relationship that is giving me problems when updating the destination entity.

class Seo
{
      id; <- PK
      title;
      description;
      state() <- reverse to-one relationship to State
}

class State
{
       id; <- PK
       name;
       seoid; <- FK to Seo (id)
       seo(); <- optional to-one relationship to Seo
}

When I first enter an Seo to a State, all seems fine, all properties of Seo are saved and are related to the corresponding State. But then, when I update it I get this exception.


Unable to map destination State for relationship state in entity Seo. To one relationships must be joined on the primary key of the destination.
java.lang.IllegalArgumentException: Unable to map destination State for relationship state in entity Seo. To one relationships must be joined on the primary key of the destination.
at com .webobjects .eoaccess .EORelationship._sourceRowToForeignKeyMapping(EORelationship.java: 1134)
at com .webobjects .eoaccess.EORelationship._foreignKeyForSourceRow(EORelationship.java: 1148)
at com .webobjects .eoaccess .EODatabaseContext ._objectFaultWithSnapshotRelationshipEditingContext (EODatabaseContext.java:2346)
at com .webobjects .eoaccess .EODatabaseContext ._fireDeferredFaultWithSourceObject(EODatabaseContext.java:2401)
at com .webobjects .eoaccess .EOAccessDeferredFaultHandler .createFaultForDeferredFault(EOAccessDeferredFaultHandler.java:49)
at com .webobjects .eocontrol.EOCustomObject.willReadRelationship(EOCustomObject.java: 1279)
at er .extensions .eof.ERXGenericRecord.willReadRelationship(ERXGenericRecord.java:358)
at com.webobjects.eocontrol._EOMutableKnownKeyDictionary $Initializer $ _LazyGenericRecordBinding .valueInObject(_EOMutableKnownKeyDictionary.java:614)
at com .webobjects .eocontrol.EOCustomObject.storedValueForKey(EOCustomObject.java:1634)
at com.webobjects.eocontrol.EOCustomObject.snapshot(EOCustomObject.java: 525)
at com .webobjects .eocontrol.EOEditingContext.objectWillChange(EOEditingContext.java: 2813)
at er.extensions.eof.ERXEC.objectWillChange(ERXEC.java:769)
at com .webobjects .eocontrol .EOObserverCenter .notifyObserversObjectWillChange(EOObserverCenter.java:399)
at com .webobjects.eocontrol.EOCustomObject.willChange(EOCustomObject.java: 333)
at com.webobjects.eocontrol._EOMutableKnownKeyDictionary $Initializer $ _GenericRecordBinding .setValueInObject(_EOMutableKnownKeyDictionary.java:579)
at com .webobjects .eocontrol.EOCustomObject.takeStoredValueForKey(EOCustomObject.java: 1663)
at er .extensions .eof.ERXGenericRecord.takeStoredValueForKey(ERXGenericRecord.java: 1290)
at com.bossing.wo.bids.db._Seo.setDescription(_Seo.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun .reflect .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun .reflect .DelegatingMethodAccessorImpl .invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.webobjects.foundation.NSKeyValueCoding$ValueAccessor $1.setMethodValue(NSKeyValueCoding.java:643)
at com.webobjects.foundation.NSKeyValueCoding $_MethodBinding.setValueInObject(NSKeyValueCoding.java:1150)
at com .webobjects .eocontrol.EOCustomObject.takeValueForKey(EOCustomObject.java:1529)
at er .extensions .eof.ERXGenericRecord.takeValueForKey(ERXGenericRecord.java:1282)
at com.webobjects.foundation.NSKeyValueCoding $Utility.takeValueForKey(NSKeyValueCoding.java:469)
at com.webobjects.foundation.NSValidation $DefaultImplementation.validateTakeValueForKeyPath(NSValidation.java: 679)
at com .webobjects .eocontrol .EOCustomObject.validateTakeValueForKeyPath(EOCustomObject.java:1335)
at com.webobjects.foundation.NSValidation $Utility.validateTakeValueForKeyPath(NSValidation.java:502)
at com.webobjects.foundation.NSValidation $DefaultImplementation.validateTakeValueForKeyPath(NSValidation.java: 687)
at com .webobjects .eocontrol .EOCustomObject.validateTakeValueForKeyPath(EOCustomObject.java:1335)
at com.webobjects.foundation.NSValidation $Utility.validateTakeValueForKeyPath(NSValidation.java:502)


Is my entity modeling correct? Any ideas how I can resolve this?

Thanks,
Amiel
--
socket error: unable to connect to 127.0.0.1
_______________________________________________
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: Help with optional to-one relationship
      • From: Amiel Montecillo <email@hidden>
References: 
 >Help with optional to-one relationship (From: Amiel Montecillo <email@hidden>)

  • Prev by Date: Help with optional to-one relationship
  • Next by Date: Re: Help with optional to-one relationship
  • Previous by thread: Help with optional to-one relationship
  • Next by thread: Re: Help with optional to-one relationship
  • Index(es):
    • Date
    • Thread