数据库结构如下
create table t_role(
role_id  varchar(10) not null primary key,
role_name   varchar(20) not null,
role_indite varchar(100) not null);create table t_role_authority(
roleAuth_id varchar(32) not null primary key,
authority_name  varchar(20) not null ,
role_id   varchar(10) not null ,
Constraint ref_t_role_authority foreign key(role_id) references t_role(role_id));两个实体类如下
public class RoleAuthorInfo implements java.io.Serializable{ private static final long serialVersionUID = 1L;

private String roleAuthID;
private String authorityName; 
}public class RoleInfo implements java.io.Serializable{ private static final long serialVersionUID = 1L;

private String roleID = null; //角色ID
private String roleName = null; //角色名称
private String roleDepict= null;  //角色描述
private Set roleAuthName;
}hibernat 配置信息
<class name="RoleInfo" table="t_role">
<id name="roleID" column="role_id">
<generator class="sequence">
<param name="sequence">role_sqe_id</param>
</generator>
</id>
<property name="roleName" column="role_name"></property>
<property name="roleDepict" column="role_indite"></property>
<set name="roleAuthName" cascade="all-delete-orphan">
<key column="role_id"/>
<one-to-many class="RoleAuthorInfo"/>
</set>
</class>第二个配置信息
<class name="RoleAuthorInfo" table="t_role_authority">
<id name="roleAuthID" column="roleAuth_id">
<generator class="uuid"/>
</id>
<property name="authorityName" column="authority_name" />
</class>
我想删除表t_role 里面的内容的时候把t_role_authority 里面的内容也删除 要如何做呢
                    session=sessionFactory.openSession();

//开启事务
Transaction tra = session.beginTransaction();
RoleInfo info = new RoleInfo();
info.setRoleID(roleID);
RoleInfo item = (RoleInfo)session.load(RoleInfo.class,info.getRoleID());
session.delete(item);我用上面的方法来做 它报如下错误 Could not execute JDBC batch update  和     无法更新 ("SCOTT"."T_ROLE_AUTHORITY"."ROLE_ID") 为 NULL  为什么呢?  谁能帮我解决下 我急等着用 谢谢了!!!!

解决方案 »

  1.   

    <one-to-many class="RoleAuthorInfo"/>  添加属性cascade=“all”试试
    <one-to-many class="RoleAuthorInfo" cascade="all"/>
      

  2.   

    先谢谢你了 
    <one-to-many class="RoleAuthorInfo" />里面不能加cascade="all"的 外面的set才可以 但是我已经加了 
      

  3.   

    你给的东西太乱了,理不清逻辑关系。一对多的话,要在一的一端添加多的那个实体,字段就用多的ID  另外多的那一端设置lazy="false"
      

  4.   

    你的实体类有没有set,get方法,构造函数?另外多的那一端设置lazy="false"
      

  5.   

    get set 方法是有的 因为要帖代码出来 所以我给省略掉了 
      

  6.   

    类里是一的一端写集合,多的一端写对象
    一的一端的配置文件是:
    <set>
      <key column=""/>
      <one-to-many class=""/>
    </set> 
    多的一端的本置文件是:
    <many-to-one name="" column="" not-null="true">初学者,也是来学习来了