※ [本文轉錄自 java 看板 #1W2jyiQF ]
作者: lueichun (= =) 看板: java
標題: [問題] Hibernate的oneToMany與ManyToOne的意義
時間: Fri Jan 22 22:20:26 2021
※狀況概述:
以下的程式,有City跟Country兩個類別,city跟country是多對一的關係,
程式可以正常運作:
City類別:
public class City {
private int cityId;
private String cityName;
private Country country;
......
}
City的映射檔:
<hibernate-mapping package="com.test.vo">
<class name="City" table="CITY">
<id name="cityId" column="CITY_ID">
<generator class="increment"/>
</id>
<property name="cityName" column="CITY_NAME" />
<many-to-one name="country" column="COUNTRY_ID" class="com.test.vo.Country"
cascade="all"/><!