Spring JPA getJpaTemplate find 多个参数 的设置

来源:互联网 发布:java api管理系统 编辑:程序博客网 时间:2024/06/03 13:03

在Spring和 JPA的结合中,对数据库的操作时,SQL的书写形式 和 Hibernate 的不一样。


Hibernate中的形式为:

select user from User user where user.userName=? and user.userPassword=?


而 JPA 中的形式为:

select user from User user where user.userName=?1 and user.userPassword=?2


即在 问号(?)后面 加上 参数的位置,数字是从1开始的。