To-many relationship of hibernate

Many relationship can be seen as two-to-many

To-many configuration:

导入TreeNode.hbm.xml,book.hbm.xml,category.hbm.xml

Mapping these documents in hibernate in

TreeNode.hbm.xml:

Once configured, tested TreeNodeDaoTest:

Test Results:

In the configuration book.hmb.xml

Label description:

table: The middle class is
middle class means that the table does not need to rely on two main entities table corresponding to the joint management of the mapping file
name: The current mapping file corresponding entity class attributes
cascade: New Laws cascade, is the current entity class corresponding to the table to delete can affect the data associated tables, delete a table will delete all the data corresponding to the table of
inverse: data center maintenance to the other side of the table

key tags:
Colum: current table t_hibernate_book primary key column segment book_id middle of the table in
many-to -many:
Colum: table representative of corresponding intermediate table t_hibernate_book removing the current table of non-primary key column of the table intermediate segment
class: cld corresponding class

 

Then tested in bookdaotest,

Book.hbm.xml to true inverse = *
* = category.hbm.xml inverse to true
* only increase data table books
* bridge table without data
* Cause: neither to maintain relations

 

 Data in the database is also added to it:

 

 

 

 

Book.hbm.xml to true inverse = *
* = category.hbm.xml inverse to true
* only increase data table books
* bridge table without data
* Cause: neither to maintain relations

 

 

 Data bridging table has not changed

 

 

 

 

 

Thanks for watching

 

Guess you like

Origin www.cnblogs.com/xhpcc/p/11317447.html