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

Using size() for collection associations in where-queries or detached criteria leads to exception #727

Open
miq opened this issue Jun 19, 2023 · 0 comments

Comments

@miq
Copy link

miq commented Jun 19, 2023

We are using Grails 5.2.5 annd GORM 7.3.2 with Hibernate5.

We have a domain object with a collection/list of other domain object and would like to do something like:

    Container.where {
        parts.size() == 1
        parts{ id == 123 }
    }.deleteAll()

As per documentation (section 7.4.5) this is supported by both where-queries and detached criteria: http://gorm.grails.org/latest/hibernate/manual/index.html#whereQueries

Doing so leads to the exception:

Caused by: org.springframework.dao.InvalidDataAccessResourceUsageException: Queries of type SizeEquals are not supported by this implementation
at org.grails.datastore.mapping.query.jpa.JpaQueryBuilder.buildWhereClauseForCriterion(JpaQueryBuilder.java:906)
at org.grails.datastore.mapping.query.jpa.JpaQueryBuilder.buildWhereClause(JpaQueryBuilder.java:859)
at org.grails.datastore.mapping.query.jpa.JpaQueryBuilder.buildWhereClause(JpaQueryBuilder.java:847)
at org.grails.datastore.mapping.query.jpa.JpaQueryBuilder.buildDelete(JpaQueryBuilder.java:143)
at org.grails.orm.hibernate.HibernateSession.lambda$deleteAll$0(HibernateSession.java:96)
at org.grails.orm.hibernate.GrailsHibernateTemplate.doExecute(GrailsHibernateTemplate.java:297)
at org.grails.orm.hibernate.GrailsHibernateTemplate.execute(GrailsHibernateTemplate.java:241)
at org.grails.orm.hibernate.HibernateSession.deleteAll(HibernateSession.java:92)
at grails.gorm.DetachedCriteria$_deleteAll_closure6.doCall(DetachedCriteria.groovy:561)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant