Search code examples
playframeworksyntax-errorsql-in

unexpected token: VALUES near line 1, column 57


JPA.em("default").createQuery("insert into USER (FULLNAME, EMAIL, USERNAME, PASSWORD) " + " VALUES (\'"+fullname+"\',\'"+email+"\',\'"+username+"\',\'"+password+"\');");

is it a wrong query? i get this error:

[IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: VALUES near line 1, column 57 [insert into USER (FULLNAME, EMAIL, USERNAME, PASSWORD) VALUES ('Doniyor','[email protected]','jurabayev','er');]]

i dont know why this is happening, the query string is actually okay, right?

would appreciate any help!

thanks


Solution

  • i think you should use

    .createNativeQuery(...);
    

    instead of

    .createQuery(...);
    

    but I'm not sure about it.

    if you are using annotations

    @Query(value = "your_query_here", nativeQuery = true)