This week's book giveaway is in the Design and Architecture forum.
We're giving away four copies of Communication Patterns: A Guide for Developers and Architects and have Jacqui Read on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Foreign Key Relationships problem in Hibernate

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have a very unique problem in Hibernate. I will try to explain the problem as clearly as possible.

I have a table A which has three columns 1, 2 and 3. These 3 columns are nullable columns.

I have a table B which has fields 4 and 5 as its compund key. Now, the table A has a foreign key relationship with table B through fields 1 and 4 and also 2 and 5.

I have another table C which has fields 6 and 7 as its compond key. The table A has a foreign key relationship with table C through fields 3 and 6 and also 2 and 7.

Now, my problem is since the field 2 in table A is related to both Table B amd table C, Hibernate is not allowing me to use insert=true and update=true for the relationships of table A and B and table A and C. If i do so, then at startup, hibernate throws me an error to set either one of the relationships as false. If i set either one of the relationships as false, then i am not able to update the database with the required value since I am explicitly setting the insert and update as false.

I need to update fields 1, 2 and 3, but the relationships is not allowing me to do so. Please let me know what can be done for the above issue.

I tried using native SQL to update the tables. But I got an exception saying that only HQL should be used for insert/update.

Please let me know if there is any other way.
 
author & internet detective
Posts: 41967
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Deepak,
Welcome to JavaRanch!

Our Hibernate experts hang out in the Object Relational Mapping forum. I'll move your post over there for you.
 
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic