数据库中2两张表
一张user表,一张pay表
department的外键在user表中做主键
则:用eclipse的自动翻转工具生成的配置文件如下
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="com.ddz.model.User" table="user" catalog="flandlordb">
<id name="username" type="java.lang.String">
<column name="username" length="20" />
<generator class="assigned" />
</id>
<property name="password" type="java.lang.String">
<column name="password" length="20" not-null="true" />
</property>
<property name="name" type="java.lang.String">
<column name="name" length="50" />
</property>
<property name="iconPath" type="java.lang.String">
<column name="icon_path" length="100" />
</property>
<property name="sex" type="java.lang.String">
<column name="sex" length="10" />
</property>
<property name="qq" type="java.lang.String">
<column name="qq" length="16" />
</property>
<property name="level" type="java.lang.String">
<column name="level" length="20" />
</property>
<property name="EMail" type="java.lang.String">
<column name="e_mail" length="50" />
</property>
<property name="idealMoney" type="java.lang.Integer">
<column name="ideal_money" />
</property>
<property name="regtime" type="java.util.Date">
<column name="regtime" length="10" />
</property>
<property name="wincount" type="java.lang.Integer">
<column name="wincount" />
</property>
<property name="failcount" type="java.lang.Integer">
<column name="failcount" />
</property>
<property name="lastlogin" type="java.sql.Timestamp">
<column name="lastlogin" length="19" />
</property>
<set name="competitions" inverse="true" lazy="false">
<key>
<column name="user_id" length="20" />
</key>
<one-to-many class="com.ddz.model.Competition" />
</set>
<set name="paies" inverse="true" lazy="false">
<key>
<column name="user_id" length="20" />
</key>
<one-to-many class="com.ddz.model.Pay" />
</set>
</class>
</hibernate-mapping>
//---------------------------pay如下--------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="com.ddz.model.Pay" table="pay" catalog="flandlordb">
<id name="id" type="java.lang.Integer">
<column name="id" />
<generator class="assigned" />
</id>
<many-to-one name="user" class="com.ddz.model.User" fetch="select" lazy="false">
<column name="user_id" length="20" />
</many-to-one>
<property name="money" type="java.lang.Integer">
<column name="money">
<comment>?铮?濂革铮ㄦ0铮?</comment>
</column>
</property>
<property name="date" type="java.sql.Timestamp">
<column name="date" length="19" />
</property>
</class>
</hibernate-mapping>