我有两个hibernate映射文件。我已经尝试了几种使用此documentation来绑定它们的方法。你能告诉我最简单的方法吗?
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="model.Player" table="PLAYER">
<id name="playerId" type="int" >
<column name="ID" precision="5" scale="0"/>
<generator class="sequence">
<param name="sequence">PLAYER_SEQ</param>
</generator>
</id>
<!-- ... -->
</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">
<hibernate-mapping>
<class name="model.AnnualFee" table="ANNUAL_FEE">
<id name="id" type="int" >
<column name="ID" precision="5" scale="0"/>
<generator class="increment"/>
</id>
<property name="playerId" type="int">
<column name="PLAYER_ID" length="20" not-null="true" />
</property>
<!-- ... -->
</class>
</hibernate-mapping>
我希望它们与playerId
相关联,并且能够进一步执行outer join
。
编辑:
我想这样做:
<id name="playerId" type="int" >
<column name="ID" precision="5" scale="0"/>
<generator class="sequence">
<param name="sequence">PLAYER_SEQ</param>
</generator>
</id>
<set name="playerId" table="ANNUAL_FEE">
<key column="PLAYER_ID"/>
<one-to-many class="model.AnnualFee" />
</set>
但是,然后想法会突出显示getPlayerId()
:
“为字段&get; getPlayerId&#39;”
配置了多个属性
答案 0 :(得分:0)
<many-to-one name="player" insert="false" update="false" class="model.Player" fetch="select">
<column name="ID" not-null="true" />
</many-to-one>
添加到AnnualFee
不只是int playerId
而是Player
public class AnnualFee {
private int id;
private Player player;
//...