在我的 java spring boot 应用程序中,我正在使用 postgresql。我正在尝试运行以下查询
String update = "update User" +
"set temporaryRandomToken = :randomToken" +
"where id = :userId";
org.hibernate.query.Query<?> sql = createHql(update)
.setParameter("randomToken", "12aswqq")
.setParameter("userId", 1);
问题是,当我运行查询时它会提示
MismatchedTokenException: expecting "set", found '='
userId
和 randomToken
必须动态更改,所以不要向我提供静态查询字符串。
最佳答案
你需要在两行的开头有一个空格(在“set”和“where”之前):
String update = "update User" +
" set temporaryRandomToken = :randomToken" +
" where id = :userId";
关于java - MismatchedTokenException : expecting "set", 发现 '=',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47153189/