• 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
Shared EO loading with multiple models
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Shared EO loading with multiple models


  • Subject: Shared EO loading with multiple models
  • From: Fabian Peters <email@hidden>
  • Date: Mon, 2 Oct 2006 20:00:35 +0200

Hi,

I stumbled across a known bug in the loading of shared EOs when an App uses multiple models. I got it working now, so this post is more to add some info for future reference and maybe have some WO-guru look into it. ;-)

[1] <http://en.wikibooks.org/wiki/Programming:WebObjects/EOF/ Using_EOF/Problems>
[2] <http://wonder.cvs.sourceforge.net/wonder/Wonder/Common/ Frameworks/ERExtensions/Sources/er/extensions/ERXSharedEOLoader.java? revision=1.9&view=markup>


Unlike the case of Francis Labrie [1], changing the model load order did not help in my case. However, the ERXSharedEOLoader [2], originally written by Kelly Hawks, did. Kelly's description of the situation, as quoted in the class, does not match mine. I actually have EOs that are shared in each of two models. With this setup, I get:

INFO 11:04:55 14,99 MB used/6,81 MB free er.transaction.adaptor.Exceptions:85 - JDBC Exception occured: java.lang.IllegalStateException: sqlStringForKeyValueQualifier: attempt to generate SQL for com.webobjects.eocontrol.EOKeyValueQualifier (myAttribute = 'myValue') failed because attribute identified by key 'myAttribute' was not reachable from from entity 'sharedEO1'

This is the same problem Francis ran into. In my case I've got a Foo object in Model A, which has a relation to a Bar object in Model B. Bar has a relation to Baz (Model B) and Baz has relations to two shared EOs, sharedEO1 and sharedEO2 (both Model B). This triggers the exception:


NSArray arr = EOUtilities.objectsMatchingKeyAndValue (ec, Foo.ENTITY_NAME,
Foo.ATTRIBUTE_myAttribute, sess().getFoo ().myAttribute());


Instead of just fetching Foo records matching the given attribute, the code results in a fetch for each of the shared EOs. This is I can understand, but then, a fetch is prepared for the Foo entity, which looks like this when logged at PostgresqlExpression.prepareSelectExpressionWithAttributes():

PostgresqlExpression.prepareSelectExpressionWithAttributes:
NSArray: (<EOAttribute someAttributeOfSharedEO2 2757372>, <EOAttribute eoid 4488117>, <EOAttribute message 1435205>, <EOAttribute private 12647729>, <EOAttribute anotherAttributeOfSharedEO2 3070175>, <EOAttribute temporary 10507805>)
FetchSpec: <class com.webobjects.eocontrol.EOFetchSpecification (entityName=Foo,
qualifier=((myAttribute = 'myValue')),
isDeep=true, usesDistinct=false,
sortOrdering=null,
hints=null,
_prefetchingRelationshipKeyPaths = null)>

I don't really know what is happening here, but what I see is that the attributes listed, all belong to sharedEO2, while the entityName is correctly set to "Foo". So, somehow the attributes of the last fetch for all instances of sharedEO2 end up in the fetch for Foo and the fetch is recognised to be for entity sharedEO2 - albeit the correctly set entityName.


On subsequent invocations, the attributes all belong to "Foo" and the fetch completes normally.

I've had enough for today and won't look into this any further. Maybe somebody gets some clues from my notes...

cheers

Fabian

P.S.: These are the call stacks for the fetch for "sharedEO1":

EOUtilities.objectsMatchingKeyAndValue(EOEditingContext, String, String, Object) line: 168
EOUtilities.objectsMatchingValues(EOEditingContext, String, NSDictionary) line: 193
ERXEC(EOEditingContext).objectsWithFetchSpecification (EOFetchSpecification) line: 4500
ERXEC.objectsWithFetchSpecification(EOFetchSpecification, EOEditingContext) line: 763
ERXEC(EOEditingContext).objectsWithFetchSpecification (EOFetchSpecification, EOEditingContext) line: 4114
EOObjectStoreCoordinator.objectsWithFetchSpecification (EOFetchSpecification, EOEditingContext) line: 539
EODatabaseContext.objectsWithFetchSpecification(EOFetchSpecification, EOEditingContext) line: 3346
EODatabaseContext._objectsWithFetchSpecificationEditingContext (EOFetchSpecification, EOEditingContext) line: 3205
EODatabaseChannel.selectObjectsWithFetchSpecification (EOFetchSpecification, EOEditingContext) line: 215
EODatabaseChannel._selectWithFetchSpecificationEditingContext (EOFetchSpecification, EOEditingContext) line: 789
EODatabaseChannel._setCurrentEntityAndRelationshipWithFetchSpecification (EOFetchSpecification) line: 722
EODatabaseChannel.setCurrentEntity(EOEntity) line: 142
EODatabaseChannel.setEntity(EOEntity) line: 113
NSSelector._safeInvokeSelector(NSSelector, Object, Object[]) line: 108
NSSelector.invoke(Object, Object[]) line: 354
Method.invoke(Object, Object...) line: 585
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
EODatabaseContext.registeredDatabaseContextForModel(EOModel, EOEditingContext) line: 1137
EODatabaseContext.registeredDatabaseContextForModel(EOModel, EOObjectStoreCoordinator) line: 1114
EODatabaseContext._preloadSharedObjectsWithModel(EOModel) line: 1324
EOSharedEditingContext.bindObjectsWithFetchSpecification (EOFetchSpecification, String) line: 384
EOSharedEditingContext(EOEditingContext).objectsWithFetchSpecification (EOFetchSpecification, EOEditingContext) line: 4114
EOObjectStoreCoordinator.objectsWithFetchSpecification (EOFetchSpecification, EOEditingContext) line: 539
EODatabaseContext.objectsWithFetchSpecification(EOFetchSpecification, EOEditingContext) line: 3346
EODatabaseContext._objectsWithFetchSpecificationEditingContext (EOFetchSpecification, EOEditingContext) line: 3205
EODatabaseChannel.selectObjectsWithFetchSpecification (EOFetchSpecification, EOEditingContext) line: 215
EODatabaseChannel._selectWithFetchSpecificationEditingContext (EOFetchSpecification, EOEditingContext) line: 878
JDBCChannel.selectAttributes(NSArray, EOFetchSpecification, boolean, EOEntity) line: 178
JDBCExpressionFactory (EOSQLExpressionFactory).selectStatementForAttributes(NSArray, boolean, EOFetchSpecification, EOEntity) line: 226
PostgresqlExpression.prepareSelectExpressionWithAttributes(NSArray, boolean, EOFetchSpecification) line: 511


and the failing fetch for "Foo": (subsequent successful fetches for Foo are identical)

EOUtilities.objectsMatchingKeyAndValue(EOEditingContext, String, String, Object) line: 168
EOUtilities.objectsMatchingValues(EOEditingContext, String, NSDictionary) line: 193
ERXEC(EOEditingContext).objectsWithFetchSpecification (EOFetchSpecification) line: 4500
ERXEC.objectsWithFetchSpecification(EOFetchSpecification, EOEditingContext) line: 763
ERXEC(EOEditingContext).objectsWithFetchSpecification (EOFetchSpecification, EOEditingContext) line: 4114
EOObjectStoreCoordinator.objectsWithFetchSpecification (EOFetchSpecification, EOEditingContext) line: 539
EODatabaseContext.objectsWithFetchSpecification(EOFetchSpecification, EOEditingContext) line: 3346
EODatabaseContext._objectsWithFetchSpecificationEditingContext (EOFetchSpecification, EOEditingContext) line: 3205
EODatabaseChannel.selectObjectsWithFetchSpecification (EOFetchSpecification, EOEditingContext) line: 215
EODatabaseChannel._selectWithFetchSpecificationEditingContext (EOFetchSpecification, EOEditingContext) line: 878
JDBCChannel.selectAttributes(NSArray, EOFetchSpecification, boolean, EOEntity) line: 178
JDBCExpressionFactory (EOSQLExpressionFactory).selectStatementForAttributes(NSArray, boolean, EOFetchSpecification, EOEntity) line: 226
PostgresqlExpression.prepareSelectExpressionWithAttributes(NSArray, boolean, EOFetchSpecification) line: 511


_______________________________________________
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:
    • wo tools
      • From: <email@hidden>
  • Next by Date: wo tools
  • Next by thread: wo tools
  • Index(es):
    • Date
    • Thread