Re: Strange problem with database, relationship and editingContext
Re: Strange problem with database, relationship and editingContext
- Subject: Re: Strange problem with database, relationship and editingContext
- From: Chuck Hill <email@hidden>
- Date: Fri, 17 Nov 2006 08:47:28 -0800
Hi,
On Nov 17, 2006, at 8:38 AM, Daniele Corti wrote:
2006/11/17, Chuck Hill <email@hidden>: Hi Daniele,
The problem appears to be in your model, not in your code.
On Nov 17, 2006, at 7:50 AM, Daniele Corti wrote:
> Hi all,
> I have a strange error on a simple
> EOSortOrdering.sortedArrayUsingKeyOrderArray
>
> this is the errer message:
> Application: AffittiV2Admin
> Error: java.lang.IllegalStateException:
> sqlStringForKeyValueQualifier: attempt to generate SQL for
> com.webobjects.eocontrol.EOKeyValueQualifier
> (_eofInv_LKRegion_children.className
If you see _eofinv in an error message, it means that EOF is
generating an inverse (going the other way) relationship for
something in your model. If your model is not setup correctly (or,
in a few cases, if you hit a bug in EOF), EOF is not able to
correctly generate this inverse relationship.
Unrelated: storing the class name in the database is unusual. :-)
Well, the structure is complicated: LKLocation is an abstract
entity, it has 5 Subclass (or subentity, I don't know how to call
them),
I don't either. :-) I use both terms.
LKCountry, LKState, LKCity, LKRegion, LKLink, but they are all
stored in the same table LK_LOCATION. The class name is stored to
Understand how to manage them.
OK
> = 'class com.gestweb.locationkit.LKRegion') failed because
> attribute identified by key '_eofInv_LKRegion_children.className'
> was not reachable from from entity 'AFProperty'
What is AFProperty? How does this relate to LKRegion? It seems to
be complaining about not being able to navigate from an AFProperty to
an LKRegion.
AFProperty is another entity and is related to LKLocation with a to
one relationship called "parent" but I don't think the problem
could be
an empty relation, because the AFProperty can be related just to a
LKCity entity.
i think that probably _is_ the problem. If AFProperty can _only_ be
related to ak LKCity, then the parent relationship should point
directly to LKCity, not to AFProperty. It looks like EOF wants to be
able to make an inverse relationship from LKRegion to AFProperty and
can't get there from an LKRegion.
the children relationship is a to many relationship of LKRegion
from the attribute locationId to the attribute parentId of LKLocation
The problem is: I don't really understand why to access at an
attribute or at the editingContext of the object in the NSArray
returned by children(), I need to access from AFProperty...
Part of EOF's job is to ensure that the object graph is consistent.
It is probably trying to create faults for relationships and can't
figure out how to navigate them (as they are impossible).
Chuck
> Reason: sqlStringForKeyValueQualifier: attempt to generate
SQL for
> com.webobjects.eocontrol.EOKeyValueQualifier
> (_eofInv_LKRegion_children.className = 'class
> com.gestweb.locationkit.LKRegion') failed because attribute
> identified by key '_eofInv_LKRegion_children.className' was not
> reachable from from entity 'AFProperty'
>
> well the code that generate this error is:
>
> public NSArray childrenSortedByName() {
> NSLog.out.appendln("CHILDREN: "+children()+"\neditingContext:
> "+this.editingContext()+" Session.default: "+GiveSession.session
> ().defaultEditingContext());
> NSLog.out.appendln("Child: "+((EOEnterpriseObject)children
> ().lastObject()).editingContext());
> return EOSortOrdering.sortedArrayUsingKeyOrderArray (children(),
> new NSArray(ascendingNameOrdering));
> }
>
> the error is fired on the second NSLog
>
> children() is a method of my LKRegion class, extending
> EOEnterpriseObject, generated from EOModeler, to manage the table
> LK_LOCATION in my db.
> children is not a field, but the result of a to many relation from
> LK_LOCATION to LK_LOCATION, and the method return a NSArray.
>
> I have the feeling that the problem is show in this log, but I
> really don't understand why the Object : CHILDREN:
> com.webobjects.eocontrol._EOCheapCopyMutableArray[ddeda2] should
> causes an error while calling editingContext();
>
> CHILDREN: ({values = {className = "class
> com.gestweb.locationkit.LKRegion"; images = "<
> com.webobjects.eocontrol._EOCheapCopyMutableArray 1b0caf
> (<EOAccessArrayFaultHandler images _EOIntegralKeyGlobalID[LKRegion
> (java.lang.Integer)1000448]>)>"; modificationDate = 2006-11-17
> 15:40:26 Etc/GMT; name = "Regions"; creationDate = 2006-11-17
> 13:56:49 Etc/GMT; children = "<
> com.webobjects.eocontrol._EOCheapCopyMutableArray ddeda2
> (<EOAccessArrayFaultHandler children _EOIntegralKeyGlobalID
> [LKRegion (java.lang.Integer)1000448]>)>"; parent =
> "<com.gestweb.locationkit.LKCountry e80317 _EOIntegralKeyGlobalID
> [LKCountry (java.lang.Integer)1000313]>"; }; this =
> "<com.gestweb.locationkit.LKRegion e5d007 _EOIntegralKeyGlobalID
> [LKRegion (java.lang.Integer)1000448]>"; })
>
> editingContext: com.webobjects.eocontrol.EOEditingContext@6c9f0f
> Session.default: com.webobjects.eocontrol.EOEditingContext@6c9f0f
>
> Child: com.webobjects.eocontrol.EOEditingContext@6c9f0f
>
> CHILDREN: com.webobjects.eocontrol._EOCheapCopyMutableArray [ddeda2]
>
> editingContext: com.webobjects.eocontrol.EOEditingContext@6c9f0f
> Session.default: com.webobjects.eocontrol.EOEditingContext@6c9f0f
>
--
Daniele Corti
AIM: S0CR4TE5
Messenger: email@hidden
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
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