Blazebit / blaze-persistence

Rich Criteria API for JPA providers
https://persistence.blazebit.com
Apache License 2.0
741 stars 90 forks source link

UnsupportedOperationException in String concat @Mapping after upgrading to Hibernate 6.6.0.Final #1927

Closed lukaskirner closed 3 weeks ago

lukaskirner commented 3 months ago

Description

Exception is thrown for a string concatenation in a mapping @Mapping("family.name || '-' || family.subName") after upgrading Hibernate to 6.6.0.Final. Worked with Hibernate 6.5.2.Final before. CONCAT is also not working

Expected behavior

No exception

Actual behavior

Caused by: java.lang.IllegalArgumentException: There are error(s) in entity views!
Exception while resolving type for attribute familyFullName[com.example.dto.CustomerDevice.getFamilyFullName]:
java.lang.UnsupportedOperationException: Not implemented for org.hibernate.query.sqm.produce.function.StandardFunctionReturnTypeResolvers$1
    at org.hibernate.query.sqm.produce.function.FunctionReturnTypeResolver.resolveFunctionReturnType(FunctionReturnTypeResolver.java:46)
    at com.blazebit.persistence.integration.hibernate.base.function.HibernateSqmFunctionDescriptorAdapter.getReturnType(HibernateSqmFunctionDescriptorAdapter.java:133)
    at com.blazebit.persistence.view.impl.ScalarTargetResolvingExpressionVisitor.resolveToFunctionReturnType(ScalarTargetResolvingExpressionVisitor.java:619)
    at com.blazebit.persistence.view.impl.ScalarTargetResolvingExpressionVisitor.visit(ScalarTargetResolvingExpressionVisitor.java:503)
    at com.blazebit.persistence.parser.expression.FunctionExpression.accept(FunctionExpression.java:96)
    at com.blazebit.persistence.view.impl.metamodel.MetamodelBuildingContextImpl.getPossibleTargetTypes(MetamodelBuildingContextImpl.java:379)
    at com.blazebit.persistence.view.impl.metamodel.AttributeMapping.getPossibleTargetTypes(AttributeMapping.java:374)
    at com.blazebit.persistence.view.impl.metamodel.AttributeMapping.getType(AttributeMapping.java:446)
    at com.blazebit.persistence.view.impl.metamodel.AttributeMapping.getJavaType(AttributeMapping.java:362)
    at com.blazebit.persistence.view.impl.metamodel.AbstractAttribute.<init>(AbstractAttribute.java:158)
    at com.blazebit.persistence.view.impl.metamodel.AbstractMethodAttribute.<init>(AbstractMethodAttribute.java:66)
    at com.blazebit.persistence.view.impl.metamodel.AbstractMethodSingularAttribute.<init>(AbstractMethodSingularAttribute.java:69)
    at com.blazebit.persistence.view.impl.metamodel.attribute.MappingMethodSingularAttribute.<init>(MappingMethodSingularAttribute.java:34)
    at com.blazebit.persistence.view.impl.metamodel.MethodAttributeMapping.getMethodAttribute(MethodAttributeMapping.java:795)
    at com.blazebit.persistence.view.impl.metamodel.ManagedViewTypeImpl.<init>(ManagedViewTypeImpl.java:322)
    at com.blazebit.persistence.view.impl.metamodel.ViewTypeImpl.<init>(ViewTypeImpl.java:51)
    at com.blazebit.persistence.view.impl.metamodel.ViewMappingImpl.getManagedViewType(ViewMappingImpl.java:890)
    at com.blazebit.persistence.view.impl.metamodel.MetamodelBuildingContextImpl.getManagedViewType(MetamodelBuildingContextImpl.java:234)
    at com.blazebit.persistence.view.impl.metamodel.ViewMetamodelImpl.<init>(ViewMetamodelImpl.java:88)
    at com.blazebit.persistence.view.impl.EntityViewManagerImpl.<init>(EntityViewManagerImpl.java:271)
    at com.blazebit.persistence.view.impl.EntityViewConfigurationImpl.createEntityViewManager(EntityViewConfigurationImpl.java:257)

Steps to reproduce

Any Spring Boot project with the following versions of Hibernate.

build.gradle.kts

implementation("org.hibernate.orm:hibernate-core:6.6.0.Final") // 6.5.2.Final works
implementation("org.hibernate.orm:hibernate-jpamodelgen:6.6.0.Final") // 6.5.2.Final works
kapt("org.hibernate.orm:hibernate-jpamodelgen:6.6.0.Final") // 6.5.2.Final works

implementation("com.blazebit:blaze-persistence-integration-hibernate-6.2:1.6.12")
implementation("com.blazebit:blaze-persistence-integration-spring-data-3.3:1.6.12")
@EntityView(Device::class)
data class CustomerDevice(
    @IdMapping
    var id: Long,

    @Mapping("family.name || '-' || family.subName") // <-- doesn't like this String concat
    var familyFullName: String
)

Environment

Version: 1.6.12
JPA-Provider: Hibernate 6.6.0.Final
Framework: Spring Boot v3.3.2

EugenMayer commented 3 months ago

We have issues with 6.6.0.Final too

 Exception while resolving type for attribute pageCount[de.kontextwork.dw.platform.borl.space.model.view.SpaceWithPageCountView.getPageCount]:
  java.lang.UnsupportedOperationException: Not implemented for org.hibernate.query.sqm.produce.function.StandardFunctionReturnTypeResolvers$1
    at org.hibernate.query.sqm.produce.function.FunctionReturnTypeResolver.resolveFunctionReturnType(FunctionReturnTypeResolver.java:46)
    at com.blazebit.persistence.integration.hibernate.base.function.HibernateSqmFunctionDescriptorAdapter.getReturnType(HibernateSqmFunctionDescriptorAdapter.java:133)
    at com.blazebit.persistence.view.impl.ScalarTargetResolvingExpressionVisitor.resolveToFunctionReturnType(ScalarTargetResolvingExpressionVisitor.java:619)
    at com.blazebit.persistence.view.impl.ScalarTargetResolvingExpressionVisitor.visit(ScalarTargetResolvingExpressionVisitor.java:503)
    at com.blazebit.persistence.parser.expression.FunctionExpression.accept(FunctionExpression.java:96)
EugenMayer commented 1 month ago

Just as a heads up, neither 6.6.1 works in this case

jcputney commented 1 month ago

This is preventing us from upgrading to Hibernate 6.6, is there any update on a potential fix?