Reputation: 171
I have a query starting with REPLACE. When I use it directly in MySQL
console everything is fine, so query is ok. However, when I put it in my code like this:
@Query("REPLACE INTO WeekAggregate...
There is an error:
web - 2016-10-05 10:35:44,297 [localhost-startStop-1] ERROR o.h.hql.internal.ast.ErrorCounter - line 1:1: unexpected token: REPLACE
antlr.NoViableAltException: unexpected token: REPLACE
How could I fix this? Is REPLACE not supported in HQL?
Upvotes: 0
Views: 732
Reputation: 171
I changed my query to native SQL query by using nativeQuery = true flag.
Upvotes: 0
Reputation: 15389
HQL
is trasversal to underlying DBMS. So some functions you're using in your SQL can't be interpretated by HQL.
You have two ways:
change your HQL query (in this case you can rewrite your query with an DELETE/INSERT statement)
you can write your query in SQL and you can use a method createSqlQuery so the interpreter, runs the query as SQL native query.
Upvotes: 1