54341
2011-12-18 12:04
浏览 230
已采纳

hibernate中oracle级联删除问题

我建了两张表,关系为many-to-one

hibernate.cfg.xml

 

<!-- SQL dialect -->
        <property name="dialect">org.hibernate.dialect.OracleDialect</property>


        <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">true</property>

        <!-- Drop and re-create the database schema on startup -->
        <!--
        <property name="hbm2ddl.auto">create</property>
        -->
        <property name="hbm2ddl.auto">create</property>
        <mapping resource="com/ssy/hibernate/bean/Person.hbm.xml"/>
        <mapping resource="com/ssy/hibernate/bean/Team.hbm.xml"/>

person表

 

 

<hibernate-mapping>

    <class name="com.ssy.hibernate.bean.Person" table="PERSON">
        <id name="id" column="pid">
            <!--<generator class="native"/>-->
            <generator class="sequence" >
                <param name="sequence">person_seq</param>
            </generator>        
        </id>
        <property name="name"/>
        <many-to-one name="team" column="tid" class="com.ssy.hibernate.bean.Team" />
      
    </class>

</hibernate-mapping>

 team表

 

<hibernate-mapping>

    <class name="com.ssy.hibernate.bean.Team" table="TEAM">
        <id name="id" column="tid">
            <!--<generator class="native"/>-->
            <generator class="sequence" >
                <param name="sequence">team_seq</param>
            </generator>        
        </id>
        <property name="name"/> 
    </class>

</hibernate-mapping>

 我现在要实现,删除一个teamid,下面的子记录都被删除,要怎么配置级联删除

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题