aspose file tools*
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 Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate disable foreign keys" Watch "hibernate disable foreign keys" New topic
Author

hibernate disable foreign keys

gustavo sanchez
Greenhorn

Joined: May 18, 2007
Posts: 5
I need to disable the creation of foreign keys when <property name="hbm2ddl.auto">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
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

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.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
gustavo sanchez
Greenhorn

Joined: May 18, 2007
Posts: 5
thanks !
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: hibernate disable foreign keys