gsartori opened a new issue, #15955:
URL: https://github.com/apache/grails-core/issues/15955
### Expected Behavior
where {} queries fail when accessing a property of an embedded component,
even though the property is referenced using the expected dotted notation.
Hibernate throws the following exception:
```
org.hibernate.QueryException: Criteria objects cannot be created directly on
components.
Create a criteria on owning entity and use a dotted property to access
component property: extRef1
```
The query already uses a dotted property (`extRef1.value`), so it appears
that GORM is translating the where {} closure into a Hibernate Criteria
incorrectly.
The same happens with:
```
extRef1.provider == "SAP"
so the issue does not appear to be related to the =~ operator, but to
accessing any property of an embedded component.
```
## Expected behavior
The query should be translated into a predicate on the embedded property
(e.g. `extRef1.value`) and execute successfully.
### Actual Behaviour
Hibernate throws:
```
org.hibernate.QueryException: Criteria objects cannot be created directly on
components.
Create a criteria on owning entity and use a dotted property to access
component property: extRef1
```
### Steps To Reproduce
## Domain model
```
abstract class SystemManaged {
ExternalRef extRef1
static embedded = ['extRef1']
}
class ExternalRef {
String provider
String value
}
class WorkItem extends SystemManaged {
String description
}
```
## Query
```
def query = WorkItem.where {}
String search = "ABC"
query = query.where {
extRef1.value =~ "%${search}%"
}
```
### Environment Information
Grails: 7.1.0
### Example Application
_No response_
### Version
7.1.0
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]