Happy Wednesday/Thursday all,

I'm posting this here to remind my future self and future googlers since this 
is a somewhat obscure issue with unexpected results. 

Earlier today I was having a problem where calling a toMany relationship was 
returning the expected number of objects in an NSArray, but the array had 4 
pointers to one single object in it instead of 4 pointers to 4 individual 
objects.

In the database there were four rows that were identical except for one field 
(DUE_DATE). It seemed that somehow EOF was saying that these rows all represent 
one object and then put 4 pointers to that one object in the array. 

Anybody see where this is going? Because this is the thing that had me stumped 
for hours.

The problem was the table's Primary Key, or more accurately, its lack there of. 
The table in the DB (Oracle) didn't have a PK defined. Since EOF doesn't like 
PKless entities, someone (not me! I swear.) had simply picked a bunch of 
non-null attributes in EOModeler that would approximate a PK. The problem is 
that this PK was not unique. So EOF only created one EO, but then inserted it 
into the NSArray 4 times.

In this situation the DUE_DATE field can be null, so it can't be part of the 
PK. Now I've got to get the DBAs to put a PK on the table.

Dave

David Avendasora
Senior Software Engineer
K12, Inc.

*****
WebObjects Documentation Wiki : 
http://wiki.objectstyle.org/confluence/display/WO/
*****
WebObjects API: 
http://developer.apple.com/legacy/mac/library/documentation/MacOSXServer/Reference/WO54_Reference/index.html
*****

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to