Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalMutationQueryException when using native "select for update" query #3247

Open
davidgiga1993 opened this issue Nov 25, 2024 · 1 comment
Assignees
Labels
type: bug Something isn't working

Comments

@davidgiga1993
Copy link

Expected Behavior

The select statement should return data without failing

Actual Behaviour

The select statement throws an exception as micronaut calls hibernate's executeUpdate instead of a select:

org.hibernate.query.IllegalMutationQueryException: Expecting a native mutation query, but found `SELECT * FROM task t WHERE t.request_id = :requestId AND t.status = :status
AND JSON_CONTAINS(t.parent_ids, :parentId) = true
FOR UPDATE

Downgrading to micronaut 4.6.0 (micronaut-data 4.9.0) resolves the issue

Steps To Reproduce

  1. Create a repository with the following:
@Query(value = """
        SELECT * FROM task t WHERE t.request_id = :requestId AND t.status = :status
        AND JSON_CONTAINS(t.parent_ids, :parentId) = true
        FOR UPDATE
        """, nativeQuery = true)
    public abstract List<Task> tasksWithParentId(String requestId, String parentId, String status);
  1. Execute the query with any parameters

Environment Information

  • Micronaut 4.7.1
  • Micronaut data 4.10.4
  • JDK 22

Example Application

No response

Version

4.7.1

@radovanradic
Copy link
Contributor

Regression from this #3236

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants