unexpected token: VALUES near line 1, column 57

doniyor picture doniyor · Jun 20, 2012 · Viewed 16.7k times · Source
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

Answer

duffy356 picture duffy356 · Jun 20, 2012

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)