Skip to content
Advertisement

How should I pass values into JPQL query?

I’m working on test, that will check if object had been saved into database. Test will save object with unique values and after that I want to fetch this object from database and check if it is not null. Id is auto generated, so I need to find this object by name.

My test looks like this:

after running it I get error:

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column ‘Jon’ in ‘where clause’

How should this query look like?

Advertisement

Answer

You have to set the parameters on the query:

More about querying you can find here:

https://docs.oracle.com/javaee/7/tutorial/persistence-querylanguage002.htm#BNBRG https://www.objectdb.com/java/jpa/query

Or you buy a book https://www.apress.com/de/book/9781484234198

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement