【发布时间】:2015-12-22 17:01:00
【问题描述】:
有两个实体。
- Route(Arrival、ArrivalID 和 Departure、DepartureID)作为位置
- 位置(到达、出发)作为路线
位置与路由表是一对多的关系。
我正在尝试设置。
路由.xml
<many-to-one name="departure" class="com.nakisa.agency.Location" fetch="select" insert="false" update="false">
<column name="locationID" not-null="true" />
</many-to-one>
<many-to-one name="arrival" class="com.nakisa.agency.Location" fetch="select" insert="false" update="false">
<column name="locationID" not-null="true" />
</many-to-one>
位置.xml
<set name="arrivals" table="Routes" inverse="true" lazy="true" fetch="select">
<key>
<column name="arrivalID" not-null="true" />
</key>
<one-to-many class="com.nakisa.agency.Route" />
</set>
<set name="departures" table="Routes" inverse="true" lazy="true" fetch="select">
<key>
<column name="departureID" not-null="true" />
</key>
<one-to-many class="com.nakisa.agency.Route" />
</set>
即使我在路线中设置了departmentID,但由于departmentID 为null,我收到错误消息。
如何更正这些映射才能正常工作
【问题讨论】:
标签: java xml hibernate one-to-many hibernate-onetomany