gpt4 book ai didi

java - org.datanucleus.store.query.QueryCompilerSyntaxException : Identifier expected at character 12 in "u.username== value"

转载 作者:行者123 更新时间:2023-12-02 07:15:29 25 4
gpt4 key购买 nike

org.datanucleus.store.query.QueryCompilerSyntaxException: Identifier expected at character 12 in "u.username== value"

这是我尝试执行的查询:

try{
Query q=em.createQuery("select u from UserJ u where u."+key+"== value");
q.setParameter("value",value );
return q.getResultList().isEmpty();
}
catch(PersistenceException x)
{
System.out.println(x.getLocalizedMessage());}
finally{
em.close();
}

key在哪里通过值传递:“用户名”

并且value通过值传递:"test"

最佳答案

您的语法不正确,请尝试以下查询:

Query q = em.createQuery("select u from UserJ u where u."+key+" = :value");

关于java - org.datanucleus.store.query.QueryCompilerSyntaxException : Identifier expected at character 12 in "u.username== value",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14982213/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com