我的数据库中有 3 个表
- 人
- 地址
- 个人地址
这是脚本 sql
CREATE TABLE IF NOT EXISTS `address` (
`address_id` int(11) NOT NULL AUTO_INCREMENT,
`address` varchar(30) NOT NULL,
PRIMARY KEY (`address_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;
CREATE TABLE IF NOT EXISTS `person` (
`person_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(30) NOT NULL,
PRIMARY KEY (`person_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;
CREATE TABLE IF NOT EXISTS `person_address` (
`person_id` int(11) NOT NULL,
`address_id` int(11) NOT NULL,
PRIMARY KEY (`person_id`,`address_id`),
KEY `address_id` (`address_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `person_address`
ADD CONSTRAINT `person_address_ibfk_2` FOREIGN KEY (`address_id`) REFERENCES `address` (`address_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `person_address_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `person` (`person_id`) ON DELETE CASCADE ON UPDATE CASCADE;
这是 hibernate.reveng.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd">
<hibernate-reverse-engineering>
<schema-selection match-catalog="manyToManyTest"/>
<table-filter match-name="person_address"/>
<table-filter match-name="address"/>
<table-filter match-name="person"/>
</hibernate-reverse-engineering>
问题是在生成pojos和hbm文件时,没有生成personAddress pojo(hibernate.cfg.xml中没有条目<mapping resource="pojos/PersonAddress.hbm.xml"/>
),为什么?