Wednesday, May 05, 2010

No Row with the Given Identifier Exists: [contact#0]

So I was setting up coldfusion 9 orm and dumping an object that had lots of related objects, an they had lots of related objects etc.. I kept getting the above error when outputting a one-to-many related object. After searching the database I noticed that that particular foreign key was being set to a 0, instead of a null value, but both those values where present in the linking table.

The solution was to use the missingrowignored="true" option in my orm definition. The record with id = 0 didn't exist and cf 9 orm tried pulling a record with that value (usually it expects a null value when nothing related exists). This caused it to error but I also got a positive from hasContact(). Anyway the missingrowignored="true" was the fix.

4 comments:

Unknown said...

Such a well written post.. Thnkx for sharing this post!
Thank You
ColdFusion Developer

Josh Curtiss said...

ROCK ON. Thank you for this little post.

Roben Rajan said...

Thanks for sharing. Saved a lot of time

My Works said...
This comment has been removed by the author.