Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hibernate disable foreign keys

 
gustavo sanchez
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
gustavo sanchez
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic