自动生成的 xml mapping file里不支持component属性
自动生成的xml mapping file会根据Student.java和Address.java分别生成两个mapping file,然后在Student的mapping文件中有一个many-to-one的属性。代码如下:
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- Generated 2017-8-24 15:05:51 by Hibernate Tools 3.5.0.Final --> <hibernate-mapping> <class name="hibernate.model.component.Address" table="ADDRESS"> <id name="postcode" type="java.lang.String"> <column name="POSTCODE" /> <generator class="assigned" /> </id> <property name="phone" type="java.lang.String"> <column name="PHONE" /> </property> <property name="address" type="java.lang.String"> <column name="ADDRESS" /> </property> </class> </hibernate-mapping>
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- Generated 2017-8-24 15:05:51 by Hibernate Tools 3.5.0.Final --> <hibernate-mapping> <class name="hibernate.model.Student" table="STUDENT"> <id name="sid" type="int"> <column name="SID" /> <generator class="assigned" /> </id> <property name="sname" type="java.lang.String"> <column name="SNAME" /> </property> <property name="gender" type="java.lang.String"> <column name="GENDER" /> </property> <property name="birthday" type="java.util.Date"> <column name="BIRTHDAY" /> </property> <many-to-one name="address" class="hibernate.model.component.Address" fetch="join"> <column name="ADDRESS" /> </many-to-one> <property name="picture" type="java.sql.Blob"> <column name="PICTURE" /> </property> </class> </hibernate-mapping>