@Query(value = "select name,author,price from Book b where b.name = :name AND b.author=:author AND b.price=:price")
List<Book> findByNamedParam(@Param("name") String name, @Param("author") String author,
@Param("price") long price);
@Transactional
@Modifying
@Query("UPDATE Person p SET p.email = :email WHERE p.id = :id")
void updatePersonEmail(@Param("id") Integer id, @Param("email") String email);
@Transactional
@Modifying(clearAutomatically = true)
@Query(value = "update StockOut sc set sc.receivedPersonId=?1,sc.receivedPerson=?2,sc.receivedDate=?3 where stockOutCode=?4")
int receipt(Long uid, String uname, Date createDate, String soCode);
备注:
1.更新StockOut表下一些字段, 这里使用了不是原生的sql语句,所以不要加nativeQuery = true。
2.@Transactional 注解用于提交事务,若没有带上这句,会报事务异常提示。
3.@Modifying(clearAutomatically = true) 自动清除实体里保存的数据
jpa
最新推荐文章于 2021-02-18 17:37:36 发布