【问题标题】:Hibernate Mapping is getting removed but rows from the table are not getting deletedHibernate Mapping 被删除,但表中的行没有被删除
【发布时间】:2020-06-05 09:05:38
【问题描述】:

我在 2 个表(一对多)之间有一个休眠映射。

    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>

当我做line.getSchedule().clear()。表之间的映射被删除。但是,这些行仍然存在于表中。我不想使用查询来删除行。

请帮忙。 TIA

【问题讨论】:

  • 你能分享你的代码吗?

标签: java spring-boot hibernate hibernate-mapping


【解决方案1】:

你在清除数据后运行yourRepository.save(yourEntity);吗?这应该将更改提交到数据库。

【讨论】:

  • 我也这样做了。但仍然没有删除行
  • 您能分享一个您尝试运行的代码示例吗?
猜你喜欢
  • 2016-06-15
  • 1970-01-01
  • 2016-12-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多