hibernate-orm icon indicating copy to clipboard operation
hibernate-orm copied to clipboard

HHH-14200 Invalid SQL generated while using clause with count of collection-valued attribute

Open NathanQingyangXu opened this issue 4 years ago • 0 comments

https://hibernate.atlassian.net/browse/HHH-14200

The root cause is we didn't invoke 'initText()' for collection type in DotNode#resolve() as in the following snippet:

                else if ( propertyType.isEntityType() ) {
			// The property is another class..
			checkLhsIsNotCollection();
			dereferenceEntity( (EntityType) propertyType, implicitJoin, classAlias, generateJoin, parent, parentPredicate );
			initText();
		}
		else if ( propertyType.isCollectionType() ) {
			// The property is a collection...
			checkLhsIsNotCollection();
			dereferenceCollection( (CollectionType) propertyType, implicitJoin, false, classAlias, parent );
		}
		else {
			// Otherwise, this is a primitive type.
			if ( !CollectionProperties.isAnyCollectionProperty( propertyName ) ) {
				checkLhsIsNotCollection();
			}
			dereferenceType = DereferenceType.PRIMITIVE;
			initText();
		}

Adding the missing `initText() fixed the issue.

NathanQingyangXu avatar Sep 01 '20 16:09 NathanQingyangXu