Hibernate级联删除(一对多)

 

  
  
  
  
  1. 当级联属性cascade="all"时,发现无法删除对一端的数据 
  2. <set name="tripBusTravelSet" table="trip_bus_travel_depa_info" lazy="false" inverse="false" 
  3.         cascade="all" sort="unsorted"
  4.         <key column="TRIP_BUS_TRAVEL_ID" /> 
  5.         <one-to-many class="com.myway.followme.model.bus.TripBusTravelDepaInfo" /> 
  6.     </set>
  7.  
  8. 然后改成cascade="all-delete-orphan"时,可以实施级联删除
  9. <set name="tripBusTravelSet" table="trip_bus_travel_depa_info" lazy="false" inverse="false"
    cascade="all-delete-orphan" sort="unsorted">
    <key column="TRIP_BUS_TRAVEL_ID" />
    <one-to-many class="com.myway.followme.model.bus.TripBusTravelDepaInfo" />
    </set>

 

你可能感兴趣的:(Hibernate,职场,级联删除,休闲,级联操作)