Skip to content

Error when trying to perform a single field update action using JPA-QL #14601

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

Open
ilmoralito opened this issue Nov 1, 2017 · 3 comments
Open

Comments

@ilmoralito
Copy link

I'm trying to perform an update action in a single field using gorm data services through grails.gorm.services.Query. In the documentation I found an example very similar to my case of use

@Query("update ${Book book} set ${book.title} = $newTitle where book.title = $oldTitle")
Number updateTitle(String newTitle, String oldTitle)

The code that I try is the following:

@Query("update ${Activity activity} set ${activity.state} = $state where activity.id = $id")
Activity updateState(final String state, final Serializable id)

I am getting a query exception org.grails.orm.hibernate.exceptions.GrailsQueryException with the following caused by message

Invalid query [UPDATE anotherdemo.Activity as activity SET activity.state = :p0 WHERE activity.id = :p1] for domain class [anotherdemo.Activity]

Please visit this link to a github repository with an example app that reproduces the issue

Environment Information

  • Operating System: Ubuntu 16.04
  • Grails Version: 3.3.0.M2
  • JDK Version: Using java version 8u121

Thanks for your time

@jeffscottbrown
Copy link
Contributor

The return type appears to be an issue. The change I made at jeffscottbrown/demo-app-for-updating-single-field@9431502 works.

This looks like a problem in the Data Service compiler.

@graemerocher
Copy link
Contributor

Not really a problem in the compiler, the query doesn't return anything, so how does one obtain a reference to the Activity instance?

@graemerocher
Copy link
Contributor

Granted I think this query should fail to compile

@jameskleeh jameskleeh transferred this issue from apache/grails-core Nov 1, 2018
@jdaugherty jdaugherty transferred this issue from apache/grails-data-mapping Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants