apache / apache/grails-core

Using multi-tenant discriminator mode, IN queries are broken

Open
#14,464 3 comments 0 reactions 1 assignee Claimed by @graemerocher View on GitHub
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

I have an example app to show the issue. Just start it and bootstrap will fail. I have 3 levels of objects using multi-tenant support (subdomain based). Anyhow when I do a query from a child object for related objects I get a SQL error that one of the parameters (the IN statement criteria) is missing.

```
Caused by: org.h2.jdbc.JdbcSQLException: Parameter "#2" is not set; SQL statement:
select this_.id as id1_3_0_, this_.version as version2_3_0_, this_.tenant_id as tenant_i3_3_0_, this_.date_created as date_cre4_3_0_, this_.last_updated as last_upd5_3_0_, this_.name as name6_3_0_, this_.activity as activity7_3_0_, this_.date_trashed as date_tra8_3_0_ from contact_activity this_ where this_.date_trashed=? and this_.id in (?) [90012-193]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException.get(DbException.java:155)
at org.h2.expression.Parameter.checkSet(Parameter.java:81)
at org.h2.command.Prepared.checkParameters(Prepared.java:164)
at org.h2.command.CommandContainer.query(CommandContainer.java:109)
at org.h2.command.Command.executeQuery(Command.java:201)
at org.h2.jdbc.JdbcPreparedStatement.executeQuery(JdbcPreparedStatement.java:110)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:70)
... 88 common frames omitted
```
This example has a namedQuery but also I've tried where queries and regular criteria queries with the same result.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.