you have restricting qualifiers on the PK's? you just blew my mind.

On Mar 29, 2010, at 11:47 AM, David Avendasora wrote:

> Hi all,
> 
> Sometimes you just need to share things that bite you. I have been having 
> problems with objectWithPrimaryKeyValue.
> 
> Here's what I was calling:
> 
> EOUtilities.objectWithPrimaryKeyValue(ec, ENTITY_NAME, Long.valueOf(0))
> 
> When it runs, I get:
> 
> 10:48:59 MyApp[9003] DEBUG NSLog  -  evaluateExpression: 
> <com.webobjects.jdbcadaptor.EROracleExpression: "SELECT t0.CODE, 
> t0.DESCRIPTION FROM STATUSCODE t0 WHERE t0.CODE = ?" withBindings: 1:0(id)>
> 10:48:59 MyApp[9003] DEBUG NSLog  - 1 row(s) processed
> 10:48:59 MyApp[9003] DEBUG NSLog  -  === Commit Internal Transaction
> 10:48:59 MyApp[9003] WARN  NSLog  - 
> <com.webobjects.appserver._private.WOComponentRequestHandler>: Exception 
> occurred while handling request:
> com.webobjects.eoaccess.EOUtilities$MoreThanOneException: Selected more than 
> one item for primary key {id = 0; } in entity SamsStatusCode.
> 
> The CODE in the DB is the PK, and I've executed the SQL and it returns 
> exactly one row, just like you'd expect and the NSLog statement above says, 
> yet I'm getting the more than one item for PK error.
> 
> Steve Meyer came up with the answer: Just because you are getting on SQL row 
> back, doesn't mean that it doesn't represent more than one EO.
> 
> This Entity/Table is part of a Single Table Inheritance structure, and there 
> are two oddities about the restricting qualifiers:
> 
> 1) They are on the Primary Key column. For example: "id = 0 or id = 30 or id 
> = 31"
> 2) They define _ranges_ as well as individual values. For example: "id > 1799 
> and id < 1810"
> 
> This seems to work just fine, except when we have one Entity that has no 
> restricting qualifier, so when you call 
> EOUtilities.objectWithPrimaryKeyValue(ec, ENTITY_NAME, Long.valueOf(0))
> you get two EOs back. Because two different Entities' restricting qualifier 
> match "id = 0" .
> 
> Happy Monday.
> 
> Dave
> _______________________________________________
> 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/mschrag%40mdimension.com
> 
> This email sent to msch...@mdimension.com

 _______________________________________________
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