question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error message doesn't mention the causing line: Panache-Hibernate

See original GitHub issue

Describe the bug

I called jobRepository.listAll(Sort.by("dueWeek").and("readyWeek").and("name").and("id"))) but Job doesn’t have dueWeek property any more.

I should get an error message that told me I made a mistake in that line.

Instead, I got an error message “could not prepare statement” and “Column “DUEWEEK” not found”, which made me think I had to restart quarkus:dev because the database somehow didn’t create-drop properly.

Expected behavior

An error message that includes “MaintenanceScheduleResource” line 98 which is the line that has jobRepository.listAll(Sort.by("dueWeek").and("readyWeek").and("name").and("id")))

Actual behavior

2021-10-25 12:31:33,363 INFO  [io.quarkus] (Quarkus Main Thread) Installed features: [agroal, cdi, hibernate-orm, hibernate-orm-panache, hibernate-orm-rest-data-panache, jdbc-h2, narayana-jta, optaplanner, optaplanner-jackson, resteasy, resteasy-jackson, smallrye-context-propagation, vertx, webjars-locator]
2021-10-25 12:31:34,223 WARN  [org.hib.eng.jdb.spi.SqlExceptionHelper] (executor-thread-0) SQL Error: 42122, SQLState: 42S22
2021-10-25 12:31:34,225 ERROR [org.hib.eng.jdb.spi.SqlExceptionHelper] (executor-thread-0) Column "DUEWEEK" not found; SQL statement:
select job0_.id as id1_2_, job0_.crew_id as crew_id8_2_, job0_.dueDate as duedate2_2_, job0_.durationInDays as duration3_2_, job0_.endDate as enddate4_2_, job0_.name as name5_2_, job0_.readyDate as readydat6_2_, job0_.startDate as startdat7_2_ from Job job0_ order by dueWeek, readyWeek, job0_.name, job0_.id [42122-197]
2021-10-25 12:31:34,240 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-0) HTTP Request to /schedule failed, error id: 425347e4-9b73-4226-b3eb-14cf8f7c6bde-1: org.jboss.resteasy.spi.UnhandledException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not prepare statement
        at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:106)
        at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:372)
        at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:218)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:519)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
        at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
        at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:135)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:90)
        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$13.runWith(VertxCoreRecorder.java:543)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not prepare statement
        at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)
        at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1626)
        at org.hibernate.query.Query.getResultList(Query.java:165)
        at io.quarkus.hibernate.orm.panache.common.runtime.CommonPanacheQueryImpl.list(CommonPanacheQueryImpl.java:247)
        at io.quarkus.hibernate.orm.panache.runtime.PanacheQueryImpl.list(PanacheQueryImpl.java:149)
        at io.quarkus.hibernate.orm.panache.runtime.JpaOperations.list(JpaOperations.java:24)
        at io.quarkus.hibernate.orm.panache.runtime.JpaOperations.list(JpaOperations.java:10)
        at io.quarkus.hibernate.orm.panache.common.runtime.AbstractJpaOperations.listAll(AbstractJpaOperations.java:297)
        at org.acme.maintenancescheduling.persistence.JobRepository.listAll(JobRepository.java)
        at org.acme.maintenancescheduling.persistence.JobRepository_Subclass.listAll$$superforward1(JobRepository_Subclass.zig:1966)
        at org.acme.maintenancescheduling.persistence.JobRepository_Subclass$$function$$23.apply(JobRepository_Subclass$$function$$23.zig:33)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:49)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(InvocationInterceptor_Bean.zig:521)
        at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
        at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
        at org.acme.maintenancescheduling.persistence.JobRepository_Subclass.listAll(JobRepository_Subclass.zig:4612)
        at org.acme.maintenancescheduling.persistence.JobRepository_ClientProxy.listAll(JobRepository_ClientProxy.zig:262)
        at org.acme.maintenancescheduling.rest.MaintenanceScheduleResource.findById(MaintenanceScheduleResource.java:98)
        at org.acme.maintenancescheduling.rest.MaintenanceScheduleResource_Subclass.findById$$superforward1(MaintenanceScheduleResource_Subclass.zig:297)
        at org.acme.maintenancescheduling.rest.MaintenanceScheduleResource_Subclass$$function$$1.apply(MaintenanceScheduleResource_Subclass$$function$$1.zig:33)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:49)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(InvocationInterceptor_Bean.zig:521)
        at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:50)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:132)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:103)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.doIntercept(TransactionalInterceptorRequired.java:38)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.intercept(TransactionalInterceptorBase.java:57)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.intercept(TransactionalInterceptorRequired.java:32)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired_Bean.intercept(TransactionalInterceptorRequired_Bean.zig:340)
        at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
        at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
        at org.acme.maintenancescheduling.rest.MaintenanceScheduleResource_Subclass.findById(MaintenanceScheduleResource_Subclass.zig:432)
        at org.acme.maintenancescheduling.rest.MaintenanceScheduleResource.getSchedule(MaintenanceScheduleResource.java:63)
        at org.acme.maintenancescheduling.rest.MaintenanceScheduleResource_Subclass.getSchedule$$superforward1(MaintenanceScheduleResource_Subclass.zig:311)
        at org.acme.maintenancescheduling.rest.MaintenanceScheduleResource_Subclass$$function$$2.apply(MaintenanceScheduleResource_Subclass$$function$$2.zig:24)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:49)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(InvocationInterceptor_Bean.zig:521)
        at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
        at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
        at org.acme.maintenancescheduling.rest.MaintenanceScheduleResource_Subclass.getSchedule(MaintenanceScheduleResource_Subclass.zig:516)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:170)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
        at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:660)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:524)
        at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:474)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:476)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:434)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:408)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:69)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:492)
        ... 15 more
Caused by: org.hibernate.exception.SQLGrammarException: could not prepare statement
        at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:103)
        at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:37)
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
        at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:186)
        at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151)
        at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2122)
        at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2059)
        at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2037)
        at org.hibernate.loader.Loader.doQuery(Loader.java:956)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:357)
        at org.hibernate.loader.Loader.doList(Loader.java:2868)
        at org.hibernate.loader.Loader.doList(Loader.java:2850)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2682)
        at org.hibernate.loader.Loader.list(Loader.java:2677)
        at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:540)
        at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400)
        at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219)
        at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1443)
        at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1649)
        at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1617)
        ... 78 more
Caused by: org.h2.jdbc.JdbcSQLException: Column "DUEWEEK" not found; SQL statement:
select job0_.id as id1_2_, job0_.crew_id as crew_id8_2_, job0_.dueDate as duedate2_2_, job0_.durationInDays as duration3_2_, job0_.endDate as enddate4_2_, job0_.name as name5_2_, job0_.readyDate as readydat6_2_, job0_.startDate as startdat7_2_ from Job job0_ order by dueWeek, readyWeek, job0_.name, job0_.id [42122-197]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
        at org.h2.message.DbException.get(DbException.java:179)
        at org.h2.message.DbException.get(DbException.java:155)
        at org.h2.expression.ExpressionColumn.optimize(ExpressionColumn.java:150)
        at org.h2.command.dml.Select.prepare(Select.java:858)
        at org.h2.command.Parser.prepareCommand(Parser.java:283)
        at org.h2.engine.Session.prepareLocal(Session.java:611)
        at org.h2.engine.Session.prepareCommand(Session.java:549)
        at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1247)
        at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:76)
        at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:304)
        at io.agroal.pool.wrapper.ConnectionWrapper.prepareStatement(ConnectionWrapper.java:659)
        at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149)
        at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176)
        ... 94 more

How to Reproduce?

Use Panache.listAll() on a property that doesn’t exist. Notice the error message doesn’t point to where you made the mistake.

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.3.0.Final

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
loicmathieucommented, Oct 25, 2021

An error message that includes “MaintenanceScheduleResource” line 98 which is the line that has jobRepository.listAll(Sort.by(“dueWeek”).and(“readyWeek”).and(“name”).and(“id”)))

This is in the stacktrace line 22 of the stacktrace of the cause (the second exception).

0reactions
ge0ffreycommented, Jan 7, 2022

+1 for closing

Read more comments on GitHub >

github_iconTop Results From Across the Web

Quarkus with Panache getting hibernate error HHH000183
My models are defined with @Entity annotations that should allow Hibernate to find by itself the entity mappings. Here is an example with...
Read more >
StackOverflowError when executing Hibernate Panache list ...
Hi Quarkus devs, I've stumbled upon a "RESTEASY008205: JSON Binding serialization error java.lang.StackOverflowError" when executing a REST GET backed by an ...
Read more >
Panache projection doesn't work with aggregate JPQL functions
It happens because Panache generates the wrong query. The correct HQL query should be: SELECT new org.acme.hibernate.orm.panache.Result(count(f)) ...
Read more >
Simplified Hibernate ORM with Panache - Quarkus
The solution is located in the hibernate-orm-panache-quickstart directory. If your project is already configured to use other annotation processors, you will ...
Read more >
Lombok & Hibernate: How to Avoid Common Pitfalls
Lombok & Hibernate: How to Avoid Common Pitfalls · 1. You see the code that will be executed. · 2. When generating your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found