Class Person
@OneToMany
public Set<CreditCard> getCreditCardSet() {
return creditCardSet;
}
Table
CREATE TABLE `creditcard` (
`id` varchar(32) NOT NULL,
`createDate` datetime DEFAULT NULL,
`modifyDate` datetime DEFAULT NULL,
`bureau` varchar(255) DEFAULT NULL,
`number` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `person_creditcard` (
`person_id` varchar(32) NOT NULL,
`creditCardSet_id` varchar(32) NOT NULL,
PRIMARY KEY (`person_id`,`creditCardSet_id`),
UNIQUE KEY `creditCardSet_id` (`creditCardSet_id`),
KEY `FK9B9BC4B3F49C0E5E` (`person_id`),
KEY `FK9B9BC4B39629054E` (`creditCardSet_id`),
CONSTRAINT `FK9B9BC4B39629054E` FOREIGN KEY (`creditCardSet_id`) REFERENCES `creditcard` (`id`),
CONSTRAINT `FK9B9BC4B3F49C0E5E` FOREIGN KEY (`person_id`) REFERENCES `person` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
中间表生成
CREATE TABLE `person` (
`id` varchar(32) NOT NULL,
`createDate` datetime DEFAULT NULL,
`modifyDate` datetime DEFAULT NULL,
`age` int(11) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;