Hibernate__一对多 or 多对一

  一对多,多对一  初解

 

配置文件

 

ecopOrder.hbm.xml

 

<set name="ecopOrderstates" inverse="true" cascade="all"
			order-by="ORDER_STATE_ID">
			<key>
				<column name="ORDER_ID" precision="22" scale="0" />
			</key>
			<one-to-many class="jzt.ecop.model.order.EcopOrderstate" />
</set>

 

ecopOrderstate.hbm.xml

 

<many-to-one name="ecopOrder"
			class="jzt.ecop.model.order.EcopOrder" fetch="select">
			<column name="ORDER_ID" precision="22" scale="0" />
</many-to-one>

 

orderModel.xml

 

private Set<EcopOrderstate> ecopOrderstates = new HashSet<EcopOrderstate>(0);
// 订单->订单状态 1对N关系

 

orderStateModel.xml

 

private EcopOrder ecopOrder;

你可能感兴趣的:(Hibernate,xml)