Home > database >  Why hibernate one-to-many was achieved through the method of configuration files automatically gener
Why hibernate one-to-many was achieved through the method of configuration files automatically gener

Time:09-18

The console SQL statement has displayed

 
Hibernate:
The alter table member
The drop
Foreign key FK5b3s28nglgv8ksv45tenjbm2t
Hibernate:
Drop table if the exists company
Hibernate:
Drop table if the exists member
Hibernate:
The create table company (
Cid integer not null auto_increment,
Cname varchar (255),
Primary key (cid)
)
Hibernate:
The create table member (
Mid integer not null auto_increment,
Mname varchar (255),
Com_mem_id integer,
The primary key (mid)
)
Hibernate:
The alter table member
Add the constraint FK5b3s28nglgv8ksv45tenjbm2t
Foreign key (com_mem_id)
The references company (cid)



Below is the configuration file
The core configuration file
 
<? The XML version='1.0' encoding="utf-8"?>
"-//Hibernate/Hibernate Configuration DTD/3.0/EN"
"Http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd" & gt;


















Two entities corresponding configuration file
The company
 
<? The XML version="1.0"?>
"-//Hibernate/Hibernate Mapping DTD/3.0/EN"
"Http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" & gt;




Hibernate mechanism, and two-way maintain foreign keys
In more than one and the one who are outside the configuration keys
Name of the foreign key column attribute value - & gt;







Employees

 

<? The XML version="1.0"?>
"-//Hibernate/Hibernate Mapping DTD/3.0/EN"
"Http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" & gt;








I ask you, thank you
  • Related