<class name="Address" table="EDU_ADDRESS" dynamic-insert="true" dynamic-update="true"> <id name="id" column="ADD_OID" type="java.lang.Long"> <generator class="native" /> </id> <version name="version" type="java.lang.Long" access="field" column="Version" unsaved-value="null" /> <property name="addRoutea" type="java.lang.String"> <meta attribute="field-description">@param 地址位于路A</meta> <column name="ADD_ROUTEA" length="20" /> </property> <property name="addRouteb" type="java.lang.String"> <meta attribute="field-description">@param 地址位于路B</meta> <column name="ADD_ROUTEB" length="20" /> </property> <property name="addTraffic" type="java.lang.String"> <meta attribute="field-description">@param 地址交通说明</meta> <column name="ADD_TRAFFIC" length="100" /> </property> <property name="addDetail" type="java.lang.String"> <meta attribute="field-description">@param 详细地址</meta> <column name="ADD_DETAIL" length="50" /> </property> <property name="addState" type="java.lang.Integer"> <meta attribute="field-description">@param 状态(可以、不可用)</meta> <column name="ADD_STATE" not-null="true" length="1" default="0" /> </property> <many-to-one name="user" class="com.onedu.domain.User" fetch="select" cascade="none"> <column name="U_ID" not-null="true" /> </many-to-one> <many-to-one name="area" class="com.onedu.domain.Area" cascade="none" insert="false" update="false"> <column name="ADD_COUNTY" not-null="true" /> </many-to-one> <property name="addCounty" type="java.lang.Long"> <meta attribute="field-description">@param 所属区域</meta> <column name="ADD_COUNTY" not-null="true" /> </property> </class>
1.insert="false",update="false"表示在增加或修改地址的时候,不需要对area对象进行操作。2.创建对外键字段相同的属性配置。
3.在对该数据进行操作的时候,只需对addCounty属性进行操作即可,无需对area对象进行操作。
4.查询的时候,可以通过Area对象进行关联查询。