Skip to content
This repository was archived by the owner on May 28, 2026. It is now read-only.
This repository was archived by the owner on May 28, 2026. It is now read-only.

@query not working for an update statement? #297

Description

@DNWEIJ

I am trying to do an update @query, this fails

Using @query for update statements should work imho, I could not find some documentation that the @query cannot be used for update statements from spring-data-hazelcast, but could also not find an example.
From the hazelcast docs it states that update sql should work.

Question: Should it be possible to do a @query with an UPDATE statement?

During debugging, i found the following info:

Using a statement like:
@query("UPDATE table set field = '%s' WHERE id = '%d' ")

Isn't working due to some code issues I have found. I have listed some points that can be improved/enhanced to ensure an update statement can be proecessed. I think the whole parsing etc is only build for select not for updates...

Some points I found, debuggin the code:

SqlParser:
        if (token.equals(")")) { 
```
I am not fully understaning why the whole sqlparser is done. 
THe first step actually already defines the sql that should be able to work.
`StringBasedHazelcastRepositoryQuery:execute`
shows the queryString, that seems to be already sql that would be executed. 

Beside that, the processing of the SqlParser isn't handling "(" correclty, in the sense that for the UPDATE it is using the stack and this means the actual token list is wrongly defined. 

Next to that the `SqlPRedicate` isn't working as well. The `createComparison EQUAL_FACTORY`  isn't indexing the token list correctly



```
StringBasedHazelcastRepositoryQuery::execute
  String queryString = String.format(queryStringTemplate, formatParameters(parameters));
```
Using String format is a bit limiting, but works if used correctly within the @Query statement.
Would be nicer to support something like parameters:
```
@Query("select u from User u where u.firstname = :firstname")
List<User> findUsersByCustomersFirstname(@Param("firstname")String firstName);
```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions