public interface AccountDao extends JpaRepository<Account,Integer> {
@Transactional
@Modifying
@Query(value = "delete from Account where id =?1",nativeQuery = true)
void delAccount(int id);
}
本文介绍了如何在Java中使用JPA的自定义查询来实现Account的删除操作。通过定义一个AccountDao接口,继承JpaRepository,并添加@Transactional和@Modifying注解,配合@Query注解写入SQL语句,可以实现根据id删除Account记录。
public interface AccountDao extends JpaRepository<Account,Integer> {
@Transactional
@Modifying
@Query(value = "delete from Account where id =?1",nativeQuery = true)
void delAccount(int id);
}
1422
1958
2578

被折叠的 条评论
为什么被折叠?