1. 程式人生 > >“MDD”--模型驅動開發

“MDD”--模型驅動開發

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
 
 <class name="org.smth.j2ee.websoccer.domain.Player" table="players">
  <id name="id" column="playerid" type="int">
   <generator class="native"/>
  </id>
  <property name="name" type="string" column="playername" />
  <property name="nationality" type="int" length="4" column="nationality" />
  <property name="sex" type="int" length="1" column="sex" />
  <property name="age" type="int" length="3" column="age" />
  <property name="position" type="int" length="4" column="position" />
  <property name="description" type="text" column="description" />
  <many-to-one name="team" class="org.smth.j2ee.websoccer.domain.Team" column="teamid" />
 </class>
 
 <class name="org.smth.j2ee.websoccer.domain.Team" table="teams">
  <id name="id" type="int" column="teamid">
   <generator class="native"/>
  </id>
  <property name="name" type="string" column="teamname" />
  <property name="nationality" type="int" length="4" column="nationality" />
  <property name="level" type="int" length="4" column="level" />
  <set
   name="players"
   inverse="true"
   lazy="true"
   cascade="none">
   <key column="teamid" />
   <one-to-many class="org.smth.j2ee.websoccer.domain.Player" />
  </set>
  <set name="matches" table="match_team" lazy="true">
  <key>
   <column name="teamid" not-null="true"/>
  </key>
  <many-to-many class="org.smth.j2ee.websoccer.domain.Match">
   <column name="matchid" not-null="true"/>
  </many-to-many>
  </set>
 </class>
 
 <class name="org.smth.j2ee.websoccer.domain.Match" table="matches">
 <id name="id" column="matchid" type="int">
  <generator class="native" />
 </id>
 <property name="matchname" type="string" column="matchname" />
 <property name="description" type="text" column="description" />
 <set name="teams" table="match_team" lazy="true">
  <key>
   <column name="matchid" not-null="true"/>
  </key>
  <many-to-many class="org.smth.j2ee.websoccer.domain.Team">
   <column name="teamid" not-null="true"/>
  </many-to-many>
 </set>
 </class>
 
 <class name="org.smth.j2ee.websoccer.domain.User" table="users">
  <id name="id" column="userid" type="int">
   <generator class="native" />
  </id>
  <property name="username" type="string" column="username" />
  <property name="password" type="string" column="password" />
  <set
   name="squads"
   inverse="true"
   lazy="true"
   cascade="delete">
   <key column="userid" />
   <one-to-many class="org.smth.j2ee.websoccer.domain.Squad" />
  </set>
 </class>
 
 <class name="org.smth.j2ee.websoccer.domain.Squad" table="squads">
  <id name="id" column="squadid" type="int">
   <generator class="native" />
  </id>
  <property name="type" type="int" length="4" column="type" />
  <property name="finance" type="int" column="finance" />
  <many-to-one name="user" class="org.smth.j2ee.websoccer.domain.User" column="userid" />
  <set name="players" table="squad_player" lazy="true">
  <key>
   <column name="squadid" not-null="true"/>
  </key>
  <many-to-many class="org.smth.j2ee.websoccer.domain.Player">
   <column name="playerid" not-null="true"/>
  </many-to-many>
  </set>
 </class>