How to handle a combination primary key in a multi-relationship in Hibernate

zhaozj2021-02-12  201

This issue is encountered in the previous period, mainly the writing of HBM files. I built two tables. The PID in the PID and the CID in Child is a couple of relationships. The CID and OtherId in Child use primary key. As follows

PARENT table

Field name Type Length PID (PK) Character 10 Name Character 10

Child table

Field Name Type Length CID (PK) Character 10 OtherId (PK) Smallint

Name Character 10

HBM file:

Parent.hbm.xml

Child.hbm.xml

These two HBM files are mainly: and child

These two constitute a two-way association of a combined primary key in a multi-relation. In addition to writing the PO class, pay attention to the correct written by Hashcode and Equals.

转载请注明原文地址:https://www.9cbs.com/read-7044.html

New Post(0)