aspose file tools
The moose likes JDBC and Relational Databases and the fly likes Foreign Key Relationships problem in Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Meteor in Action this week in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Foreign Key Relationships problem in Hibernate" Watch "Foreign Key Relationships problem in Hibernate" New topic
Author

Foreign Key Relationships problem in Hibernate

Deepak Ram
Greenhorn

Joined: Aug 09, 2007
Posts: 12
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.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31769
    
192

Deepak,
Welcome to JavaRanch!

Our Hibernate experts hang out in the Object Relational Mapping forum. I'll move your post over there for you.


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Foreign Key Relationships problem in Hibernate