When you use HBM2DDL to automatically create a database table, you create a foreign key association for the table at the same time. The configuration is as follows.
<prop key= "Hibernate.hbm2ddl.auto" >create</prop>
To cancel the automatic creation of foreign keys, you need to configure foreign-key= "None".
The update log for Hibernate has the following description:
Changes in version 2.1.9 (xx.x.xxxx)------------------------------------* foreign-key= "None" can is used to disable Gener Ation of a foreign key.
As a result, the configuration of Hibernate ORM in the project can be annotated or used as a configuration file.
The configuration file can be configured as follows in the XML corresponding entity class (note the foreign-key= "None"):
<class name= "Org.jbpm.identity.User" table= "Jbpm_id_user" discriminator-value= "U" > <id name= "id" column= "id_" > <generator class= "native" /> </id> <discriminator type= "char" column= "Class_" /> <property name= "name" Column= "name_" /> <property name= "email" column= "EMAIL_" / > <property name= "Password" column= "Password_" /> <set name= "Memberships" cascade= "All" > <key column= "User_" /> <one-to-many class= " Org.jbpm.identity.Membership " /> </set> <set name= "Permissions" cascade= "all " table=" Jbpm_id_permissions "> <key column=" ENTITY_ " foreign-key= "None" /> <element type= " Org.jbpm.identity.hibernate.PermissionUserType "> <column name= "Class_" /> <column name= "NAME_" /> <column name= "ACTION_" /> </element> </set> </class>
Annotations can be used to configure annotations before the Get method of the corresponding class field as follows:
@JoinColumn (name= "parent_id") @ForeignKey (name = "None")
Above.
How to cancel Hibernate Hbm2ddl.auto automatically create foreign keys