JPA的语法分为如下5种:
1、count相关,返回值为int 或 long
2、exists相关,返回值只能是 boolean
3、find相关,返回值是数组List
4、findFirst相关,返回值是aaa
5、delete相关,返回值是int,删除行数
INSERT、UPDATE、DELETE这3种DML操作,返回值只能是void、int、long。且需要添加
// Modifying queries can only use void or int/Integer as return type!
// 不加 Transactional 报错:
// javax.persistence.TransactionRequiredException: Executing an update/delete query
@Transactional
// 不加Modifing 报错:
// Can not issue data manipulation statements with executeQuery().
@Modifying
@Query("update BoothPoint set count = count + 1 where id = :pointId")
fun increaseOpenCount(pointId: Long)
支持的关键词