public class RestrictedCollectionSqmTranslatorFactory extends java.lang.Object implements org.hibernate.query.sqm.sql.SqmTranslatorFactory
Translates queries the way Hibernate's standard translator does, except is empty and is not empty
on a many-to-many collection that has a restriction of its own, which they translate as size(...) = 0 and
size(...) > 0.
Hibernate 7 tests the emptiness of a collection with an exists subquery over a join to the collection.
For a many-to-many collection it puts the restriction of the collection, the where fragment of its join
table, on the join to the element, which the select 1 of that subquery never renders, so the restriction is
lost; size(...) and member of apply it to their subquery directly. A collection that shares a join
table and a key column with another one carries such a restriction (its element columns are not null), so without
it is empty would see the rows of the other collection (apache/grails-core#16748). A one-to-many collection
keeps its restriction on the main join, and every collection without a restriction keeps Hibernate's exists
subquery.
GORM registers this factory as the hibernate.query.sqm.translator setting unless the application sets one
of its own. It covers HQL and criteria queries, and the update and delete statements Hibernate translates in one
piece. An update or delete of an entity whose hierarchy spans several tables is translated by Hibernate's
multi-table converter, which this factory does not reach, so there the emptiness test still sees the rows of the
other collection. A dialect that brings a translator of its own, such as Sybase, keeps it: queries on that
database are translated as Hibernate translates them.
| Type Params | Return Type | Name and description |
|---|---|---|
|
public org.hibernate.query.sqm.sql.SqmTranslator<? extends org.hibernate.sql.ast.tree.MutationStatement> |
createMutationTranslator(org.hibernate.query.sqm.tree.SqmDmlStatement<?> sqmDmlStatement, org.hibernate.query.spi.QueryOptions queryOptions, org.hibernate.query.sqm.internal.DomainParameterXref domainParameterXref, org.hibernate.query.spi.QueryParameterBindings domainParameterBindings, org.hibernate.engine.spi.LoadQueryInfluencers loadQueryInfluencers, org.hibernate.sql.ast.spi.SqlAstCreationContext creationContext) |
|
public org.hibernate.query.sqm.sql.SqmTranslator<org.hibernate.sql.ast.tree.select.SelectStatement> |
createSelectTranslator(org.hibernate.query.sqm.tree.select.SqmSelectStatement<?> sqmSelectStatement, org.hibernate.query.spi.QueryOptions queryOptions, org.hibernate.query.sqm.internal.DomainParameterXref domainParameterXref, org.hibernate.query.spi.QueryParameterBindings domainParameterBindings, org.hibernate.engine.spi.LoadQueryInfluencers loadQueryInfluencers, org.hibernate.sql.ast.spi.SqlAstCreationContext creationContext, boolean deduplicateSelectionItems) |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#equals(java.lang.Object), java.lang.Object#getClass(), java.lang.Object#hashCode(), java.lang.Object#notify(), java.lang.Object#notifyAll(), java.lang.Object#toString(), java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int) |