Hibernate error when upgrading from 6.1.0.Final to 6.1.1.Final or later

Logs:

piped_1     | jakarta.persistence.PersistenceException: Converting `org.hibernate.sql.ast.tree.from.UnknownTableReferenceException` to JPA `PersistenceException` : Unable to determine TableReference (`videos`) for `me.kavin.piped.utils.obj.db.Video(375683657376).channel`
piped_1     | 	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:165)
piped_1     | 	at org.hibernate.query.spi.AbstractSelectionQuery.list(AbstractSelectionQuery.java:374)
piped_1     | 	at org.hibernate.query.sqm.internal.QuerySqmImpl.list(QuerySqmImpl.java:987)
piped_1     | 	at me.kavin.piped.utils.ResponseHelper.feedResponse(ResponseHelper.java:879)
piped_1     | 	at me.kavin.piped.ServerLauncher.lambda$mainServlet$28(ServerLauncher.java:257)
piped_1     | 	at io.activej.http.AsyncServlet.lambda$ofBlocking$0(AsyncServlet.java:43)
piped_1     | 	at io.activej.promise.Promise.lambda$ofBlocking$12(Promise.java:250)
piped_1     | 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
piped_1     | 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
piped_1     | 	at java.base/java.lang.Thread.run(Unknown Source)
piped_1     | Caused by: org.hibernate.sql.ast.tree.from.UnknownTableReferenceException: Unable to determine TableReference (`videos`) for `me.kavin.piped.utils.obj.db.Video(375683657376).channel`
piped_1     | 	at org.hibernate.sql.ast.tree.from.LazyTableGroup.resolveTableReference(LazyTableGroup.java:256)
piped_1     | 	at org.hibernate.query.sqm.sql.internal.EntityValuedPathInterpretation.from(EntityValuedPathInterpretation.java:318)
piped_1     | 	at org.hibernate.query.sqm.sql.internal.EntityValuedPathInterpretation.from(EntityValuedPathInterpretation.java:232)
piped_1     | 	at org.hibernate.query.sqm.sql.internal.EntityValuedPathInterpretation.from(EntityValuedPathInterpretation.java:128)
piped_1     | 	at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.lambda$visitEntityValuedPath$57(BaseSqmToSqlAstConverter.java:3833)
piped_1     | 	at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.prepareReusablePath(BaseSqmToSqlAstConverter.java:3143)
piped_1     | 	at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.prepareReusablePath(BaseSqmToSqlAstConverter.java:3105)
piped_1     | 	at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitEntityValuedPath(BaseSqmToSqlAstConverter.java:3833)
piped_1     | 	at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitEntityValuedPath(BaseSqmToSqlAstConverter.java:414)
piped_1     | 	at org.hibernate.query.sqm.tree.domain.SqmEntityValuedSimplePath.accept(SqmEntityValuedSimplePath.java:62)
piped_1     | 	at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitMemberOfPredicate(BaseSqmToSqlAstConverter.java:6399)
piped_1     | 	at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitMemberOfPredicate(BaseSqmToSqlAstConverter.java:414)
piped_1     | 	at org.hibernate.query.sqm.tree.predicate.SqmMemberOfPredicate.accept(SqmMemberOfPredicate.java:71)
piped_1     | 	at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitJunctionPredicate(BaseSqmToSqlAstConverter.java:6307)
piped_1     | 	at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitJunctionPredicate(BaseSqmToSqlAstConverter.java:414)
piped_1     | 	at org.hibernate.query.sqm.tree.predicate.SqmJunctionPredicate.accept(SqmJunctionPredicate.java:76)
piped_1     | 	at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitWhereClause(BaseSqmToSqlAstConverter.java:2259)
piped_1     | 	at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitQuerySpec(BaseSqmToSqlAstConverter.java:1830)
piped_1     | 	at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitQuerySpec(BaseSqmToSqlAstConverter.java:414)
piped_1     | 	at org.hibernate.query.sqm.tree.select.SqmQuerySpec.accept(SqmQuerySpec.java:122)
piped_1     | 	at org.hibernate.query.sqm.spi.BaseSemanticQueryWalker.visitQueryPart(BaseSemanticQueryWalker.java:211)
piped_1     | 	at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitQueryPart(BaseSqmToSqlAstConverter.java:1686)
piped_1     | 	at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitSelectStatement(BaseSqmToSqlAstConverter.java:1485)
piped_1     | 	at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitSelectStatement(BaseSqmToSqlAstConverter.java:414)
piped_1     | 	at org.hibernate.query.sqm.tree.select.SqmSelectStatement.accept(SqmSelectStatement.java:199)
piped_1     | 	at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.translate(BaseSqmToSqlAstConverter.java:707)
piped_1     | 	at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.buildCacheableSqmInterpretation(ConcreteSqmSelectQueryPlan.java:350)
piped_1     | 	at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.withCacheableSqmInterpretation(ConcreteSqmSelectQueryPlan.java:270)
piped_1     | 	at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.performList(ConcreteSqmSelectQueryPlan.java:246)
piped_1     | 	at org.hibernate.query.sqm.internal.QuerySqmImpl.doList(QuerySqmImpl.java:537)
piped_1     | 	at org.hibernate.query.spi.AbstractSelectionQuery.list(AbstractSelectionQuery.java:363)
piped_1     | 	... 8 more

Query code:

Entities:

Is this a bug/regression in hibernate? Or, would I need to update my entity to fix this?

Hi there. This looks like a bug. Did you try running with 6.1.4.Final?

Hi beikov, yes, I did, it occurs even on v6.1.5 too!

You should be able to workaround this by using root.get("channel").get("id").in(subquery) instead. Note that you’d actually have to write this code if you were using the static metamodel. I created [HHH-15648] - Hibernate JIRA to fix the issue.

1 Like