简体   繁体   English

Hibernate 映射被删除,但表中的行没有被删除

[英]Hibernate Mapping is getting removed but rows from the table are not getting deleted

I have a hibernate mapping between 2 tables (one to many).我在 2 个表(一对多)之间有一个 hibernate 映射。

    Line.hbm.xml
    /*
    some code
    */
    <list name="schedule" lazy="false" cascade="all,delete-orphan" >
            <key column="line_Id"></key>
            <list-index column="seqNo" base="1" />
            <one-to-many class="com.atc.Schedule" />
    </list>

   Schedule.hbm.xml
    <many-to-one name="line" class="com.atc.Line" lazy="false">
            <meta attribute="use-in-clone">true</meta>
            <column name="line_Id" not-null="true" />
    </many-to-one>

When i do line.getSchedule().clear() .当我做line.getSchedule().clear() The mapping between tables is removed.表之间的映射被删除。 however, the rows are still present in the table.但是,这些行仍然存在于表中。 I don't want to use query to delete the rows.我不想使用查询来删除行。

Please help.请帮忙。 TIA TIA

Are you running yourRepository.save(yourEntity);你在运行yourRepository.save(yourEntity); after clearing the data?清除数据后? That should commit the change to the DB.那应该将更改提交给数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM