简体   繁体   English

Spring Data:使用不同的方法同时删除实体吗?

[英]Spring Data: Deleting entites at the same time using different methods?

Using Spring data is it possible to run 2 queries at the same time? 使用Spring data是否可以同时运行2个查询?

I ask as I have 2 query methods that I am calling to delete from the DB. 我问一下,因为我有两种要从数据库中删除的查询方法。

However I cannot run one before the other because it gives me the "ORA-02292 integrity constraint child record found" error. 但是,我不能先运行一个,因为它给我"ORA-02292 integrity constraint child record found"错误。

Does the @Async annotation do what I am asking? @Async注释@Async我的要求吗? If so, how do I use it? 如果可以,该如何使用?

As your description, you don't need run 2 queries at the same time. 就像您的描述一样,您不需要同时运行2个查询。 So: 所以:

  • Create 2 queries with 2 different methods and call them in order you want. 使用2种不同的方法创建2个查询,然后按需要调用它们。
  • Use "cascade delete" 使用“级联删除”
  • 声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

    相关问题 Spring Data JPA 是否有任何方法可以使用方法名称解析来计算实体? - Does Spring Data JPA have any way to count entites using method name resolving? 在Spring Controller中同时执行两个方法的仅一个数据提取的最佳方法 - Best way to have only one Data Fetch for both methods in a Spring Controller Which is executed at same time Spring JPA 数据,具有相同功能的多种方法 - Spring JPA data, multiple methods with same functionality 使用带有Hibernate的Spring数据jpa的具有相同标识符的不同对象 - A different object with the same identifier using Spring data jpa with Hibernate Spring 数据 Mongodb - 同时使用 @DocumentReference 和 @Filed - Spring Data Mongodb - Using @DocumentReference and @Filed at the same time Spring Data JPARepository:如何有条件地获取子项 - Spring Data JPARepository: How to conditionally fetch children entites 两种方法同时使用注释@Asynchronous - Two methods at same time using annotation @Asynchronous 使用多个相同的方法和时间复杂度 - Using multiple of the same methods and time complexity 使用将由许多不同类型的实体组成的pojo转换休眠实体 - Converting hibernate entities, using a pojo that will be composed of numerous entites of different types 对同一类中的不同方法使用synchronized块 - Using synchronized blocks for different methods in the same class
     
    粤ICP备18138465号  © 2020-2024 STACKOOM.COM