在CrudRepository或JpaRepository的@Query()中执行许多本机查询?

时间:2016-08-07 18:45:49

标签: spring spring-data-jpa crud

如何使用CrudRepository或JpaRepository的@Query()执行许多本机查询: 例如:

@Transactional
@Modifying
@Query(value = "delete from A_B_LIST where B_LIST_ID = ?1; delete from B where ID = ?1;", nativeQuery=true)
deleteById(@Param("id") Long id);

here the schema of bd: 
 table A: |id|  table B: |id|  table A_B_LIST: |A_LIST_ID|B_LIST_ID|  foreigns keys:
          | 1|           | 1|                  |    1    |    1    |  A_B_LIST.A_LIST_ID -> A.ID
                         | 2|                  |    1    |    2    |  A_B_LIST.B_LIST_ID -> B.ID

0 个答案:

没有答案