Error when trying to perform a single field update action using JPA-QL
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
I'm trying to perform an update action in a single field using gorm data services through `grails.gorm.services.Query`. In the [documentation](http://gorm.grails.org/latest/hibernate/manual/index.html#_data_service_write_operations) 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](https://github.com/ilmoralito/demo-app-for-updating-single-field) 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
Contributor guide
Research direction
Start with the grails.gorm.services.Query data-service write-operation documentation and the linked demo app that reproduces the failure. Trace the generated update query shown in the exception; done means the single-field Activity state update executes without a GrailsQueryException and returns the expected result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100