【问题标题】:Spring Data JPA in SpringBoot 2.1.4.RELEASE Does not deleteSpring Boot 2.1.4.RELEASE 中的 Spring Data JPA 不删除
【发布时间】:2019-05-15 07:40:33
【问题描述】:

我在服务上定义了这个方法

@Transactional
public void delete(Shop shop) {

    if (LOG.isDebugEnabled()) {
        LOG.debug("deleting Shop1 [ " + shop + " ]");
    }       

    shop.getPurchases().stream()
            .forEach(p -> purchaseService.delete(p));

    shop.getPurchases().clear();

    if (LOG.isDebugEnabled()) {
        LOG.debug("deleting Shop2 [ " + shop + " ]");
    }

    shopRepository.delete(shop);

}

我也定义了这个属性:

spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
hibernate.dialect=org.hibernate.dialect.MySQLDialect

但是当我运行删除一些商店的方法时,我在控制台中没有看到任何删除语句并且商店没有被删除

【问题讨论】:

  • 您非常具体地提到了 Spring Boot 2.1.4...您是否尝试过使用其他版本的 Spring Boot?说 Spring Boot 1.x?

标签: spring hibernate spring-boot jpa spring-data-jpa


【解决方案1】:

您需要提供您的存储库类和您的 purchaseService 对象信息。如果您正在清除列表而不是为什么要在它之前删除?请提供更多相关信息以帮助您。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-19
    • 2019-09-09
    • 1970-01-01
    • 2017-05-09
    • 1970-01-01
    • 2023-04-11
    • 2017-11-29
    • 2019-06-23
    相关资源
    最近更新 更多