This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes hibernate disable foreign keys Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate disable foreign keys" Watch "hibernate disable foreign keys" New topic

hibernate disable foreign keys

gustavo sanchez

Joined: May 18, 2007
Posts: 5
I need to disable the creation of foreign keys when <property name="">update</property> is set, cause when i delete the FK and aplication restart, hibernate create all the FK again.
When i was using MySql, hibernate does not create the FK contraints, but when i switch to Microsoft SQL server, it create the constraints but i need to delete it cause im inserting data with PK of other database
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

I believe you need to map it as nullable="true" so that it doesn't automatically create a FK constraint in the DDL.

Some Databases support FK creation and some does not, that might be why you see one Database create a FK and one doesn't.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
gustavo sanchez

Joined: May 18, 2007
Posts: 5
thanks !
Consider Paul's rocket mass heater.
subject: hibernate disable foreign keys
It's not a secret anymore!