jpa – java. Lang. illegalargumentexception: you tried to set a parameter value with a string name that does not exist in the query string

I have the following named query: @ h_ 502_ 7@

@NamedQuery(
    name = "Userdetails.findByUsername",query = "SELECT u FROM Userdetails u WHERE u.username = :username"
)
getEntityManager()
    .createNamedQuery("Userdetails.findByUsername")
    .setParameter("string","%" + string + "%")
    .getResultList();

Solution

In your userdetails In the findbyusername naming query, you have a named parameter named Username: @ h_ 502_ 7@

SELECT u FROM Userdetails u WHERE u.username = :username
getEntityManager()
    .createNamedQuery("Userdetails.findByUsername")
    .setParameter("string","%" + string + "%") //<-- check here
    .getResultList();
getEntityManager()
    .createNamedQuery("Userdetails.findByUsername")
    .setParameter("username","%" + string + "%") //<-- check here
    .getResultList();
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>