util.PSQLException: 错误:列不存在(LEFT JOIN 和 @Formula 存在问题)

huangapple go评论188阅读模式
英文:

util.PSQLException: ERROR: column does not exist (problems with LEFT JOIN and @Formula)

问题

以下是翻译好的内容:

  1. 2020-08-26 16:03:01.698 ERROR 8108 --- [nio-8080-exec-9] o.h.engine.jdbc.spi.SqlExceptionHelper: 错误 coffee0_1_.order_status 不存在
  2. 位置487
  3. 2020-08-26 16:03:01.799 ERROR 8108 --- [nio-8080-exec-9] oaccC[][DispatcherServlet]: 在路径为 [] 的上下文中为 servlet [dispatcherServlet] 提供服务 (Servlet.service()) 抛出异常 [请求处理失败嵌套异常为 org.springframework.dao.InvalidDataAccessResourceUsageException: 无法提取 ResultSetSQL [n/a]嵌套异常为 org.hibernate.exception.SQLGrammarException: 无法提取 ResultSet]根本原因为
  4. org.postgresql.util.PSQLException: 错误 coffee0_1_.order_status 不存在
  5. 位置487

注意: 由于我无法返回代码部分,因此我只能为您提供已翻译的文本。如果您对翻译的内容有任何问题,请随时提问。

英文:

I am writing MVC Rest online store. I use Spring Boot, Hibernate and PostgreSQL in my project. I have drinks and want to be able to sort them when I receive them. Everything works fine, the only thing I want to do is to take drinks if the order status is active. To do this, I added a left join query to my sql, and check it in the PostgreSQL console, everything worked. Only those drinks that were in the order with the active status were displayed. But if I throw the same sql query into @Formula, then an error is displayed. What could be the problem, and how do you use it?

My database schema:

util.PSQLException: 错误:列不存在(LEFT JOIN 和 @Formula 存在问题)

Drink class with @FORMULA:

  1. @Data
  2. @Entity
  3. @NoArgsConstructor
  4. @Table(name = "drink")
  5. @Inheritance(strategy = InheritanceType.JOINED)
  6. public class Drink {
  7. @Id
  8. @GeneratedValue
  9. private Long id;
  10. private String name;
  11. private BigDecimal price;
  12. /**
  13. * Drinks count in cart
  14. */
  15. @Formula("coalesce((select sum(c.count) from cart_items c" +
  16. " left join pg_order po on c.order_id = po.id" +
  17. " where order_status = 'ACTIVE' and\n" +
  18. "c.drink_id = id), 0)")
  19. private Long drinkCountInOrder;
  20. private String about;
  21. private int weight;
  22. @Column(name = "is_deleted")
  23. private boolean isDeleted;
  24. @ManyToOne
  25. @JoinColumn(name = "packaging_id")
  26. private Packaging packaging;
  27. @ManyToOne
  28. @JoinColumn(name = "manufacturer_id")
  29. private Manufacturer manufacturer;
  30. @ManyToOne
  31. @JoinColumn(name = "country_id")
  32. private Country country;
  33. @Override
  34. public boolean equals(Object o) {
  35. if (this == o) return true;
  36. if (o == null || getClass() != o.getClass()) return false;
  37. Drink drink = (Drink) o;
  38. return isDeleted == drink.isDeleted &&
  39. Objects.equals(id, drink.id) &&
  40. Objects.equals(name, drink.name) &&
  41. Objects.equals(price, drink.price) &&
  42. Objects.equals(about, drink.about) &&
  43. Objects.equals(packaging, drink.packaging) &&
  44. Objects.equals(manufacturer, drink.manufacturer) &&
  45. Objects.equals(country, drink.country);
  46. }
  47. @Override
  48. public int hashCode() {
  49. return Objects.hash(id, name, price, about, isDeleted, packaging, manufacturer, country);
  50. }
  51. }

Coffee class extends Drink:

  1. @Setter
  2. @Entity
  3. @Table(name = "coffee")
  4. public class Coffee extends Drink {
  5. @ManyToOne
  6. @JoinColumn(name = "type_id")
  7. private CoffeeType coffeeType;
  8. @ManyToOne
  9. @JoinColumn(name = "roasting_id")
  10. private Roasting roasting;
  11. }

Order class:

  1. @Getter
  2. @Setter
  3. @Entity
  4. @NoArgsConstructor
  5. @Table(name = "pg_order")
  6. public class Order {
  7. @Id
  8. @GeneratedValue
  9. private Long id;
  10. private String address;
  11. @Column(name = "phone_number")
  12. private String phoneNumber;
  13. @Temporal(TemporalType.TIMESTAMP)
  14. @Column(name = "date_order")
  15. private Date dateOrder;
  16. @Enumerated(EnumType.STRING)
  17. @Column(name = "order_status")
  18. private OrderStatus orderStatus;
  19. @Column(name = "total_cost")
  20. private BigDecimal totalCost;
  21. @ManyToOne
  22. @JoinColumn(name = "user_id")
  23. private User user;
  24. @OneToMany(mappedBy = "order", cascade = CascadeType.ALL, orphanRemoval = true)
  25. private List<CartItem> cartItems = new ArrayList<>();
  26. @Override
  27. public String toString() {
  28. return "Order{" +
  29. "id=" + id +
  30. ", address='" + address + '\'' +
  31. ", phoneNumber='" + phoneNumber + '\'' +
  32. ", dateOrder=" + dateOrder +
  33. ", orderStatus=" + orderStatus +
  34. ", totalCost=" + totalCost +
  35. ", user=" + user +
  36. ", cartItems=" + cartItems +
  37. '}';
  38. }
  39. }

When I find all coffees, I am getting errors:

  1. 2020-08-26 16: 03: 01.698 ERROR 8108 --- [nio-8080-exec-9] o.h.engine.jdbc.spi.SqlExceptionHelper: ERROR: column coffee0_1_.order_status does not exist
  2. Position: 487
  3. 2020-08-26 16: 03: 01.799 ERROR 8108 --- [nio-8080-exec-9] oaccC [. [. [/]. [DispatcherServlet]: Servlet.service () for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n / a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet] with root cause
  4. org.postgresql.util.PSQLException: ERROR: column coffee0_1_.order_status does not exist
  5. Position: 487
  6. at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse (QueryExecutorImpl.java:2532) ~ [postgresql-42.2.14.jar: 42.2.14]
  7. at org.postgresql.core.v3.QueryExecutorImpl.processResults (QueryExecutorImpl.java:2267) ~ [postgresql-42.2.14.jar: 42.2.14]
  8. at org.postgresql.core.v3.QueryExecutorImpl.execute (QueryExecutorImpl.java:312) ~ [postgresql-42.2.14.jar: 42.2.14]
  9. at org.postgresql.jdbc.PgStatement.executeInternal (PgStatement.java:448) ~ [postgresql-42.2.14.jar: 42.2.14]
  10. at org.postgresql.jdbc.PgStatement.execute (PgStatement.java:369) ~ [postgresql-42.2.14.jar: 42.2.14]
  11. at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags (PgPreparedStatement.java:153) ~ [postgresql-42.2.14.jar: 42.2.14]
  12. at org.postgresql.jdbc.PgPreparedStatement.executeQuery (PgPreparedStatement.java:103) ~ [postgresql-42.2.14.jar: 42.2.14]
  13. at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery (ProxyPreparedStatement.java:52) ~ [HikariCP-3.4.5.jar: na]
  14. at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery (HikariProxyPreparedStatement.java) ~ [HikariCP-3.4.5.jar: na]
  15. at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract (ResultSetReturnImpl.java:57) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
  16. at org.hibernate.loader.Loader.getResultSet (Loader.java:2285) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
  17. at org.hibernate.loader.Loader.executeQueryStatement (Loader.java:2038) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
  18. at org.hibernate.loader.Loader.executeQueryStatement (Loader.java:2000) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
  19. at org.hibernate.loader.Loader.doQuery (Loader.java:951) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
  20. at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections (Loader.java:352) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
  21. at org.hibernate.loader.Loader.doList (Loader.java:2831) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
  22. at org.hibernate.loader.Loader.doList (Loader.java:2813) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
  23. at org.hibernate.loader.Loader.listIgnoreQueryCache (Loader.java:2645) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
  24. at org.hibernate.loader.Loader.list (Loader.java:2640) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
  25. at org.hibernate.loader.hql.QueryLoader.list (QueryLoader.java:506) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
  26. at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list (QueryTranslatorImpl.java:400) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
  27. at org.hibernate.engine.query.spi.HQLQueryPlan.performList (HQLQueryPlan.java:219) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
  28. at org.hibernate.internal.SessionImpl.list (SessionImpl.java:1412) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
  29. at org.hibernate.query.internal.AbstractProducedQuery.doList (AbstractProducedQuery.java:1565) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
  30. at org.hibernate.query.internal.AbstractProducedQuery.list (AbstractProducedQuery.java:1533) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
  31. at org.hibernate.query.Query.getResultList (Query.java:165) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
  32. at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getResultList (CriteriaQueryTypeQueryAdapter.java:76) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
  33. at org.springframework.data.jpa.repository.support.SimpleJpaRepository.readPage (SimpleJpaRepository.java:637) ~ [spring-data-jpa-2.3.1.RELEASE.jar: 2.3.1.RELEASE]
  34. at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll (SimpleJpaRepository.java:445) ~ [spring-data-jpa-2.3.1.RELEASE.jar: 2.3.1.RELEASE]
  35. at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll (SimpleJpaRepository.java:410) ~ [spring-data-jpa-2.3.1.RELEASE.jar: 2.3.1.RELEASE]
  36. at java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) ~ [na: na]
  37. at java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) ~ [na: na]
  38. at java.base / jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) ~ [na: na]
  39. at java.base / java.lang.reflect.Method.invoke (Method.java:566) ~ [na: na]
  40. at org.springframework.data.repository.core.support.ImplementationInvocationMetadata.invoke (ImplementationInvocationMetadata.java:72) ~ [spring-data-commons-2.3.1.RELEASE.jar: 2.3.1.RELEASE]
  41. at org.springframework.data.repository.core.support.RepositoryComposition $ RepositoryFragments.invoke (RepositoryComposition.java:382) ~ [spring-data-commons-2.3.1.RELEASE.jar: 2.3.1.RELEASE]
  42. at org.springframework.data.repository.core.support.RepositoryComposition.invoke (RepositoryComposition.java:205) ~ [spring-data-commons-2.3.1.RELEASE.jar: 2.3.1.RELEASE]
  43. at org.springframework.data.repository.core.support.RepositoryFactorySupport $ ImplementationMethodExecutionInterceptor.invoke (RepositoryFactorySupport.java:549) ~ [spring-data-commons-2.3.1.RELEASE.jar: 2.3.1.RELEASE]
  44. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:186) ~ [spring-aop-5.2.8.RELEASE.jar: 5.2.8.RELEASE]
  45. at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke (QueryExecutorMethodInterceptor.java:155) ~ [spring-data-commons-2.3.1.RELEASE.jar: 2.3.1.RELEASE]
  46. at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke (QueryExecutorMethodInterceptor.java:130) ~ [spring-data-commons-2.3.1.RELEASE.jar: 2.3.1.RELEASE]
  47. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:186) ~ [spring-aop-5.2.8.RELEASE.jar: 5.2.8.RELEASE]
  48. at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke (DefaultMethodInvokingMethodInterceptor.java:80) ~ [spring-data-commons-2.3.1.RELEASE.jar: 2.3.1.RELEASE]
  49. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:186) ~ [spring-aop-5.2.8.RELEASE.jar: 5.2.8.RELEASE]
  50. at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction (TransactionAspectSupport.java:367) ~ [spring-tx-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  51. at org.springframework.transaction.interceptor.TransactionInterceptor.invoke (TransactionInterceptor.java:118) ~ [spring-tx-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  52. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:186) ~ [spring-aop-5.2.8.RELEASE.jar: 5.2.8.RELEASE]
  53. at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke (PersistenceExceptionTranslationInterceptor.java:139) ~ [spring-tx-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  54. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:186) ~ [spring-aop-5.2.8.RELEASE.jar: 5.2.8.RELEASE]
  55. at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor $ CrudMethodMetadataPopulatingMethodInterceptor.invoke (CrudMethodMetadataPostProcessor.java:178) ~ [spring-data-jELpa.java:178) ~ [spring-data-jELpa-2.3.1.RASEEEL.1]
  56. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:186) ~ [spring-aop-5.2.8.RELEASE.jar: 5.2.8.RELEASE]
  57. at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke (ExposeInvocationInterceptor.java:95) ~ [spring-aop-5.2.8.RELEASE.jar: 5.2.8.RELEASE]
  58. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:186) ~ [spring-aop-5.2.8.RELEASE.jar: 5.2.8.RELEASE]
  59. at org.springframework.aop.framework.JdkDynamicAopProxy.invoke (JdkDynamicAopProxy.java:212) ~ [spring-aop-5.2.8.RELEASE.jar: 5.2.8.RELEASE]
  60. at com.sun.proxy. $ Proxy151.findAll (Unknown Source) ~ [na: na]
  61. at java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) ~ [na: na]
  62. at java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) ~ [na: na]
  63. at java.base / jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) ~ [na: na]
  64. at java.base / java.lang.reflect.Method.invoke (Method.java:566) ~ [na: na]
  65. at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection (AopUtils.java:344) ~ [spring-aop-5.2.8.RELEASE.jar: 5.2.8.RELEASE]
  66. at org.springframework.aop.framework.JdkDynamicAopProxy.invoke (JdkDynamicAopProxy.java:205) ~ [spring-aop-5.2.8.RELEASE.jar: 5.2.8.RELEASE]
  67. at com.sun.proxy. $ Proxy84.findAll (Unknown Source) ~ [na: na]
  68. at ru.coffeetearea.service.CoffeeService.findAll (CoffeeService.java:107) ~ [main /: na]
  69. at ru.coffeetearea.controller.CoffeeController.findAll (CoffeeController.java:71) ~ [main /: na]
  70. at java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) ~ [na: na]
  71. at java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) ~ [na: na]
  72. at java.base / jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) ~ [na: na]
  73. at java.base / java.lang.reflect.Method.invoke (Method.java:566) ~ [na: na]
  74. at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke (InvocableHandlerMethod.java:190) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  75. at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest (InvocableHandlerMethod.java:138) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  76. at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle (ServletInvocableHandlerMethod.java:105) ~ [spring-webmvc-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  77. at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod (RequestMappingHandlerAdapter.java:879) ~ [spring-webmvc-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  78. at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal (RequestMappingHandlerAdapter.java:793) ~ [spring-webmvc-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  79. at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle (AbstractHandlerMethodAdapter.java:87) ~ [spring-webmvc-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  80. at org.springframework.web.servlet.DispatcherServlet.doDispatch (DispatcherServlet.java:1040) ~ [spring-webmvc-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  81. at org.springframework.web.servlet.DispatcherServlet.doService (DispatcherServlet.java:943) ~ [spring-webmvc-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  82. at org.springframework.web.servlet.FrameworkServlet.processRequest (FrameworkServlet.java:1006) ~ [spring-webmvc-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  83. at org.springframework.web.servlet.FrameworkServlet.doGet (FrameworkServlet.java:898) ~ [spring-webmvc-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  84. at javax.servlet.http.HttpServlet.service (HttpServlet.java:634) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  85. at org.springframework.web.servlet.FrameworkServlet.service (FrameworkServlet.java:883) ~ [spring-webmvc-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  86. at javax.servlet.http.HttpServlet.service (HttpServlet.java:741) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  87. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:231) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  88. at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  89. at org.apache.tomcat.websocket.server.WsFilter.doFilter (WsFilter.java:53) ~ [tomcat-embed-websocket-9.0.36.jar: 9.0.36]
  90. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:193) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  91. at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  92. at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:320) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  93. at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke (FilterSecurityInterceptor.java:126) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  94. at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter (FilterSecurityInterceptor.java:90) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  95. at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:334) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  96. at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter (ExceptionTranslationFilter.java:118) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  97. at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:334) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  98. at org.springframework.security.web.session.SessionManagementFilter.doFilter (SessionManagementFilter.java:137) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  99. at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:334) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  100. at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter (AnonymousAuthenticationFilter.java:111) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  101. at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:334) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  102. at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter (SecurityContextHolderAwareRequestFilter.java:158) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  103. at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:334) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  104. at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter (RequestCacheAwareFilter.java:63) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  105. at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:334) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  106. at ru.coffeetearea.security.jwt.JwtTokenFilter.doFilter (JwtTokenFilter.java:33) ~ [main /: na]
  107. at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:334) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  108. at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter (LogoutFilter.java:116) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  109. at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:334) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  110. at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter (HeaderWriterFilter.java:92) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  111. at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal (HeaderWriterFilter.java:77) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  112. at org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:119) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  113. at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:334) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  114. at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter (SecurityContextPersistenceFilter.java:105) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  115. at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:334) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  116. at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal (WebAsyncManagerIntegrationFilter.java:56) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  117. at org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:119) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  118. at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:334) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  119. at org.springframework.security.web.FilterChainProxy.doFilterInternal (FilterChainProxy.java:215) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  120. at org.springframework.security.web.FilterChainProxy.doFilter (FilterChainProxy.java:178) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
  121. at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate (DelegatingFilterProxy.java:358) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  122. at org.springframework.web.filter.DelegatingFilterProxy.doFilter (DelegatingFilterProxy.java:271) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  123. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:193) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  124. at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  125. at org.springframework.web.filter.RequestContextFilter.doFilterInternal (RequestContextFilter.java:100) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  126. at org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:119) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  127. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:193) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  128. at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  129. at org.springframework.web.filter.FormContentFilter.doFilterInternal (FormContentFilter.java:93) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  130. at org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:119) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  131. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:193) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  132. at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  133. at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal (CharacterEncodingFilter.java:201) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  134. at org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:119) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
  135. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:193) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  136. at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  137. at org.apache.catalina.core.StandardWrapperValve.invoke (StandardWrapperValve.java:202) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  138. at org.apache.catalina.core.StandardContextValve.invoke (StandardContextValve.java:96) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  139. at org.apache.catalina.authenticator.AuthenticatorBase.invoke (AuthenticatorBase.java:541) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  140. at org.apache.catalina.core.StandardHostValve.invoke (StandardHostValve.java:139) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  141. at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java: 92) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  142. at org.apache.catalina.core.StandardEngineValve.invoke (StandardEngineValve.java:74) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  143. at org.apache.catalina.connector.CoyoteAdapter.service (CoyoteAdapter.java:343) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  144. at org.apache.coyote.http11.Http11Processor.service (Http11Processor.java:373) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  145. at org.apache.coyote.AbstractProcessorLight.process (AbstractProcessorLight.java:65) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  146. at org.apache.coyote.AbstractProtocol $ ConnectionHandler.process (AbstractProtocol.java:868) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  147. at org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun (NioEndpoint.java:1590) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  148. at org.apache.tomcat.util.net.SocketProcessorBase.run (SocketProcessorBase.java:49) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  149. at java.base / java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128) ~ [na: na]
  150. at java.base / java.util.concurrent.ThreadPoolExecutor $ Worker.run (ThreadPoolExecutor.java:628) ~ [na: na]
  151. at org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run (TaskThread.java:61) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
  152. at java.base / java.lang.Thread.run (Thread.java:834) ~ [na: na]

P.S.I will once again write here that a query in the sql console is separately executed with the proper result.

PROBLEM QUERY IS IN DRINK CLASS

答案1

得分: 0

我最初错误地编写了这个公式,在那里犯了一个语法错误。我忘记通过表别名(po)调用字段。

  1. @Formula("coalesce((select sum(c.count) from cart_items c" +
  2. " left join pg_order po on c.order_id = po.id" +
  3. " where po.order_status = 'ACTIVE' and\n" +
  4. "c.drink_id = id), 0)")
  5. private Long drinkCountInOrder;
英文:

I originally wrote the formula incorrectly, making a syntax error there. I forgot to call the field via the table alias(po).

  1. @Formula("coalesce((select sum(c.count) from cart_items c" +
  2. " left join pg_order po on c.order_id = po.id" +
  3. " where po.order_status = 'ACTIVE' and\n" +
  4. "c.drink_id = id), 0)")
  5. private Long drinkCountInOrder;

huangapple
  • 本文由 发表于 2020年8月26日 21:24:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/63598691.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定