Re: pulling top level of relationships
Re: pulling top level of relationships
- Subject: Re: pulling top level of relationships
- From: Ken Anderson <email@hidden>
- Date: Thu, 5 Feb 2009 17:13:30 -0500
As Chuck said, if using inheritance, prefetching those relationships
doesn't really work.
If you're worried about performance here, you might want to rethink
the structure of your tables. I'm not sure if single table
inheritance would still have this problem, but if it does, you could
always set the batch size for faulting pretty high (50? 100?) and then
there would be significantly less queries.
In my experience, this is sufficient - trying too hard to eek out
performance without trying something a little less efficient first is
often the bigger waste of time. Of course, maybe your database is in
Siberia and you're using a 56K modem...
Ken
On Feb 5, 2009, at 3:02 PM, Don Lindsay wrote:
Hello Lachlan;
I just tried setPrefetchingRelationshipKeyPaths to use this and I
still get a null for the person object. If I use the getter from
the User Java Object person() after using the
setPrefetchingRelationshipKeyPaths I get a StackOverflow Exception.
com.webobjects.foundation.NSForwardException
[java.lang.StackOverflowError] null:java.lang.StackOverflowError
at
com
.webobjects
.foundation
.NSForwardException
._runtimeExceptionForThrowable(NSForwardException.java:39)
at com.webobjects.foundation.NSKeyValueCoding
$_MethodBinding.setValueInObject(NSKeyValueCoding.java:1156)
at com.webobjects.foundation.NSKeyValueCoding
$_NumberMethodBinding.setValueInObject(NSKeyValueCoding.java:1183)
at
com
.webobjects
.eocontrol.EOCustomObject.takeStoredValueForKey(EOCustomObject.java:
1663)
at
com
.psgs
.prjmgtflx.entities.supertype._Users.setGetsspremail(_Users.java:150)
at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)
at
sun
.reflect
.DelegatingMethodAccessorImpl
.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.webobjects.foundation.NSKeyValueCoding$ValueAccessor
$1.setMethodValue(NSKeyValueCoding.java:643)
at com.webobjects.foundation.NSKeyValueCoding
$_MethodBinding.setValueInObject(NSKeyValueCoding.java:1150)
which continues for thousands of lines. Could this possibly be
caused because the Person Entity has a relationship back to the User
Entity as well as the User Entity having a relationship to the
Person entity?
If I do not use setPrefetchingRelationshipKeyPaths, and then call
the person() getter from the User object, I get the Person object
with no problems.
Ist very strange, no?
Don
On Feb 5, 2009, at 12:04 PM, Lachlan Deck wrote:
On 06/02/2009, at 3:03 AM, Don Lindsay wrote:
When I use objectsWithFetchSpecification to retrieve an Array of
User objects. (I setEntity("Users") and setIsDeep(true)).
@see EOFetchSpecification#setIsDeep.
This is not doing what you're looking for. i.e., you're not using
inheritance from your description - but a relationship.
The Relationships in the Users object are not fetched. I believe
this is due to faulting by EO.
Lazy faulting is default behaviour, correct.
I would like to retrieve the top level relationships in the object
without the EO having to make a round trip to the database, at a
later time. Is there a way to pull the top level relationships in
an Entity, or specify if I want to go deeper into the relationship
model?
to use the example of users.
User Entity:
Username attribute: String
Password attribute: String
Person attribute: Person EO Object
What I want to do is fetch all users and ensure that the Person
object is fetched when I receive the Array of EOs back from
objectsWithFetchSpecification.
fetchSpec.setPrefetchingRelationshipKeyPaths(new
NSArray<String>("person"));
with regards,
--
Lachlan Deck
_______________________________________________
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