当前位置: 代码迷 >> Java Web开发 >> one-to-one设置了级联删除,不生效是咋回事?帮忙看看,谢谢
  详细解决方案

one-to-one设置了级联删除,不生效是咋回事?帮忙看看,谢谢

热度:41   发布时间:2016-04-14 09:05:32.0
one-to-one设置了级联删除,不生效是怎么回事?帮忙看看,多谢。
各位好,我设置了如下两个类的单向级联关系,cascade设置为all或delete,通过在jsp增加的删除在删除BuserEntity的时候都不能生效生成级联的BuserInfoEntity的删除信息,请帮忙看看是怎么回事?多谢。
另我使用java编写测试程序进行删除则能够级联删除成功。

设置了以下两个实体类的配置文件:
类BuserInfoEntity:
<hibernate-mapping>
<class name="buser.entity.BuserInfoEntity" table="B_USER_INFO">
<id name="userId" type="long">
<column name="userid"></column>
<!-- <generator class="native"></generator> -->
<generator class="sequence">
<param name="sequence">seq_acc14</param>
</generator>
</id>
<property name="address" type="string" column="address"></property>
<property name="telPhone" type="string" column="telPhone"></property>
<property name="certType" type="string" column="certType"></property>
<property name="certId" type="string" column="certId"></property>
</class>
</hibernate-mapping>

类BuserEntity:
<hibernate-mapping>
<class name="buser.entity.BuserEntity" table="B_USER">
<id name="userId" type="long" column="userid">
<generator class="foreign">
<param name="property">userinfo</param>
</generator>
</id>
<property name="userName" type="string" column="username"
length="20" not-null="false"></property>
<property name="passwd" type="string" column="passwd" length="20"></property>
<one-to-one name="userinfo" cascade="delete"/>
</class>
</hibernate-mapping>
------解决思路----------------------
你是用的hibernate的删除,还是用的hql删除? 只有hibernate的增删查改才与配置的级联关系有关
  相关解决方案