wood burning stoves*
The moose likes Object Relational Mapping and the fly likes Key is not present in table error hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Key is not present in table error hibernate" Watch "Key is not present in table error hibernate" New topic
Author

Key is not present in table error hibernate

zabet tyan
Ranch Hand

Joined: Jan 14, 2009
Posts: 32
Hi, I am trying to save something into database, but i am getting this error:




What I don't understand is that the values delivery_restriction_id = 62 delivery_type_id = 343 are clearly present from this line:

Batch entry 0 insert into public.del_res_del_type_xref (delivery_restriction_id, delivery_type_id) values (62, 343) was aborted

but why does hibernate complain that key is not present. I look in both tables (delivery_restriction and delivery_type) and the id's are there.

Here's del_res_del_type_xref's script


any ideas?

Reehan Lalkhanwar
Ranch Hand

Joined: Jun 16, 2007
Posts: 106
The error only says that delivery_restriction_id = 62 is not present in delivery_restriction table.
Did you check the DB? Did you run the query on delivery_restriction for id=62 and did you get any results?


Thank you,
Reehan
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

iririr zz, please check your private messages.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
zabet tyan
Ranch Hand

Joined: Jan 14, 2009
Posts: 32


Yes it's there, if I run this sql command manually it works fine:




That's what surprises me.

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

"iririr zz", please check your private messages for an important administrative matter. Failure to do so will result in the removal of your account.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

I'm wondering what the primary key is for this table?

-Cameron McKenzie
zabet tyan
Ranch Hand

Joined: Jan 14, 2009
Posts: 32
Ok solved the problem. apparently one of my other hbm files were mapping to this table as well and it didn't like the changes when they came from the original table.

Thanks guys
 
jQuery in Action, 2nd edition
 
subject: Key is not present in table error hibernate