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

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

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

问题

以下是翻译好的内容:

2020-08-26 16:03:01.698 ERROR 8108 --- [nio-8080-exec-9] o.h.engine.jdbc.spi.SqlExceptionHelper: 错误列 coffee0_1_.order_status 不存在
位置487
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]根本原因为

org.postgresql.util.PSQLException: 错误列 coffee0_1_.order_status 不存在
位置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:

@Data
@Entity
@NoArgsConstructor
@Table(name = "drink")
@Inheritance(strategy = InheritanceType.JOINED)
public class Drink {

    @Id
    @GeneratedValue
    private Long id;

    private String name;

    private BigDecimal price;

    /**
     * Drinks count in cart
     */
    @Formula("coalesce((select sum(c.count) from cart_items c" +
            " left join pg_order po on c.order_id = po.id" +
            " where order_status = 'ACTIVE' and\n" +
            "c.drink_id = id), 0)")
    private Long drinkCountInOrder;

    private String about;

    private int weight;

    @Column(name = "is_deleted")
    private boolean isDeleted;

    @ManyToOne
    @JoinColumn(name = "packaging_id")
    private Packaging packaging;

    @ManyToOne
    @JoinColumn(name = "manufacturer_id")
    private Manufacturer manufacturer;

    @ManyToOne
    @JoinColumn(name = "country_id")
    private Country country;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Drink drink = (Drink) o;
        return isDeleted == drink.isDeleted &&
                Objects.equals(id, drink.id) &&
                Objects.equals(name, drink.name) &&
                Objects.equals(price, drink.price) &&
                Objects.equals(about, drink.about) &&
                Objects.equals(packaging, drink.packaging) &&
                Objects.equals(manufacturer, drink.manufacturer) &&
                Objects.equals(country, drink.country);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, price, about, isDeleted, packaging, manufacturer, country);
    }
}

Coffee class extends Drink:

@Setter
@Entity
@Table(name = "coffee")
public class Coffee extends Drink {

    @ManyToOne
    @JoinColumn(name = "type_id")
    private CoffeeType coffeeType;

    @ManyToOne
    @JoinColumn(name = "roasting_id")
    private Roasting roasting;
}

Order class:

@Getter
@Setter
@Entity
@NoArgsConstructor
@Table(name = "pg_order")
public class Order {

    @Id
    @GeneratedValue
    private Long id;

    private String address;

    @Column(name = "phone_number")
    private String phoneNumber;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "date_order")
    private Date dateOrder;

    @Enumerated(EnumType.STRING)
    @Column(name = "order_status")
    private OrderStatus orderStatus;

    @Column(name = "total_cost")
    private BigDecimal totalCost;

    @ManyToOne
    @JoinColumn(name = "user_id")
    private User user;

    @OneToMany(mappedBy = "order", cascade = CascadeType.ALL, orphanRemoval = true)
    private List<CartItem> cartItems = new ArrayList<>();


    @Override
    public String toString() {
        return "Order{" +
                "id=" + id +
                ", address='" + address + '\'' +
                ", phoneNumber='" + phoneNumber + '\'' +
                ", dateOrder=" + dateOrder +
                ", orderStatus=" + orderStatus +
                ", totalCost=" + totalCost +
                ", user=" + user +
                ", cartItems=" + cartItems +
                '}';
    }
}

When I find all coffees, I am getting errors:

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
  Position: 487
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

org.postgresql.util.PSQLException: ERROR: column coffee0_1_.order_status does not exist
  Position: 487
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse (QueryExecutorImpl.java:2532) ~ [postgresql-42.2.14.jar: 42.2.14]
at org.postgresql.core.v3.QueryExecutorImpl.processResults (QueryExecutorImpl.java:2267) ~ [postgresql-42.2.14.jar: 42.2.14]
at org.postgresql.core.v3.QueryExecutorImpl.execute (QueryExecutorImpl.java:312) ~ [postgresql-42.2.14.jar: 42.2.14]
at org.postgresql.jdbc.PgStatement.executeInternal (PgStatement.java:448) ~ [postgresql-42.2.14.jar: 42.2.14]
at org.postgresql.jdbc.PgStatement.execute (PgStatement.java:369) ~ [postgresql-42.2.14.jar: 42.2.14]
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags (PgPreparedStatement.java:153) ~ [postgresql-42.2.14.jar: 42.2.14]
at org.postgresql.jdbc.PgPreparedStatement.executeQuery (PgPreparedStatement.java:103) ~ [postgresql-42.2.14.jar: 42.2.14]
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery (ProxyPreparedStatement.java:52) ~ [HikariCP-3.4.5.jar: na]
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery (HikariProxyPreparedStatement.java) ~ [HikariCP-3.4.5.jar: na]
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract (ResultSetReturnImpl.java:57) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
at org.hibernate.loader.Loader.getResultSet (Loader.java:2285) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
at org.hibernate.loader.Loader.executeQueryStatement (Loader.java:2038) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
at org.hibernate.loader.Loader.executeQueryStatement (Loader.java:2000) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
at org.hibernate.loader.Loader.doQuery (Loader.java:951) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections (Loader.java:352) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
at org.hibernate.loader.Loader.doList (Loader.java:2831) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
at org.hibernate.loader.Loader.doList (Loader.java:2813) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
at org.hibernate.loader.Loader.listIgnoreQueryCache (Loader.java:2645) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
at org.hibernate.loader.Loader.list (Loader.java:2640) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
at org.hibernate.loader.hql.QueryLoader.list (QueryLoader.java:506) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list (QueryTranslatorImpl.java:400) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
at org.hibernate.engine.query.spi.HQLQueryPlan.performList (HQLQueryPlan.java:219) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
at org.hibernate.internal.SessionImpl.list (SessionImpl.java:1412) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
at org.hibernate.query.internal.AbstractProducedQuery.doList (AbstractProducedQuery.java:1565) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
at org.hibernate.query.internal.AbstractProducedQuery.list (AbstractProducedQuery.java:1533) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
at org.hibernate.query.Query.getResultList (Query.java:165) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getResultList (CriteriaQueryTypeQueryAdapter.java:76) ~ [hibernate-core-5.4.17.Final.jar: 5.4.17.Final]
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.readPage (SimpleJpaRepository.java:637) ~ [spring-data-jpa-2.3.1.RELEASE.jar: 2.3.1.RELEASE]
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll (SimpleJpaRepository.java:445) ~ [spring-data-jpa-2.3.1.RELEASE.jar: 2.3.1.RELEASE]
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll (SimpleJpaRepository.java:410) ~ [spring-data-jpa-2.3.1.RELEASE.jar: 2.3.1.RELEASE]
at java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) ~ [na: na]
at java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) ~ [na: na]
at java.base / jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) ~ [na: na]
at java.base / java.lang.reflect.Method.invoke (Method.java:566) ~ [na: na]
at org.springframework.data.repository.core.support.ImplementationInvocationMetadata.invoke (ImplementationInvocationMetadata.java:72) ~ [spring-data-commons-2.3.1.RELEASE.jar: 2.3.1.RELEASE]
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]
at org.springframework.data.repository.core.support.RepositoryComposition.invoke (RepositoryComposition.java:205) ~ [spring-data-commons-2.3.1.RELEASE.jar: 2.3.1.RELEASE]
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]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:186) ~ [spring-aop-5.2.8.RELEASE.jar: 5.2.8.RELEASE]
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke (QueryExecutorMethodInterceptor.java:155) ~ [spring-data-commons-2.3.1.RELEASE.jar: 2.3.1.RELEASE]
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke (QueryExecutorMethodInterceptor.java:130) ~ [spring-data-commons-2.3.1.RELEASE.jar: 2.3.1.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:186) ~ [spring-aop-5.2.8.RELEASE.jar: 5.2.8.RELEASE]
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke (DefaultMethodInvokingMethodInterceptor.java:80) ~ [spring-data-commons-2.3.1.RELEASE.jar: 2.3.1.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:186) ~ [spring-aop-5.2.8.RELEASE.jar: 5.2.8.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction (TransactionAspectSupport.java:367) ~ [spring-tx-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke (TransactionInterceptor.java:118) ~ [spring-tx-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:186) ~ [spring-aop-5.2.8.RELEASE.jar: 5.2.8.RELEASE]
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke (PersistenceExceptionTranslationInterceptor.java:139) ~ [spring-tx-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:186) ~ [spring-aop-5.2.8.RELEASE.jar: 5.2.8.RELEASE]
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]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:186) ~ [spring-aop-5.2.8.RELEASE.jar: 5.2.8.RELEASE]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke (ExposeInvocationInterceptor.java:95) ~ [spring-aop-5.2.8.RELEASE.jar: 5.2.8.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation.java:186) ~ [spring-aop-5.2.8.RELEASE.jar: 5.2.8.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke (JdkDynamicAopProxy.java:212) ~ [spring-aop-5.2.8.RELEASE.jar: 5.2.8.RELEASE]
at com.sun.proxy. $ Proxy151.findAll (Unknown Source) ~ [na: na]
at java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) ~ [na: na]
at java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) ~ [na: na]
at java.base / jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) ~ [na: na]
at java.base / java.lang.reflect.Method.invoke (Method.java:566) ~ [na: na]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection (AopUtils.java:344) ~ [spring-aop-5.2.8.RELEASE.jar: 5.2.8.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke (JdkDynamicAopProxy.java:205) ~ [spring-aop-5.2.8.RELEASE.jar: 5.2.8.RELEASE]
at com.sun.proxy. $ Proxy84.findAll (Unknown Source) ~ [na: na]
at ru.coffeetearea.service.CoffeeService.findAll (CoffeeService.java:107) ~ [main /: na]
at ru.coffeetearea.controller.CoffeeController.findAll (CoffeeController.java:71) ~ [main /: na]
at java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) ~ [na: na]
at java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) ~ [na: na]
at java.base / jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) ~ [na: na]
at java.base / java.lang.reflect.Method.invoke (Method.java:566) ~ [na: na]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke (InvocableHandlerMethod.java:190) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest (InvocableHandlerMethod.java:138) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle (ServletInvocableHandlerMethod.java:105) ~ [spring-webmvc-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod (RequestMappingHandlerAdapter.java:879) ~ [spring-webmvc-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal (RequestMappingHandlerAdapter.java:793) ~ [spring-webmvc-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle (AbstractHandlerMethodAdapter.java:87) ~ [spring-webmvc-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch (DispatcherServlet.java:1040) ~ [spring-webmvc-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService (DispatcherServlet.java:943) ~ [spring-webmvc-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest (FrameworkServlet.java:1006) ~ [spring-webmvc-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doGet (FrameworkServlet.java:898) ~ [spring-webmvc-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at javax.servlet.http.HttpServlet.service (HttpServlet.java:634) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.springframework.web.servlet.FrameworkServlet.service (FrameworkServlet.java:883) ~ [spring-webmvc-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at javax.servlet.http.HttpServlet.service (HttpServlet.java:741) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:231) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.apache.tomcat.websocket.server.WsFilter.doFilter (WsFilter.java:53) ~ [tomcat-embed-websocket-9.0.36.jar: 9.0.36]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:193) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:320) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke (FilterSecurityInterceptor.java:126) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter (FilterSecurityInterceptor.java:90) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:334) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter (ExceptionTranslationFilter.java:118) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:334) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at org.springframework.security.web.session.SessionManagementFilter.doFilter (SessionManagementFilter.java:137) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:334) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter (AnonymousAuthenticationFilter.java:111) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:334) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter (SecurityContextHolderAwareRequestFilter.java:158) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:334) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter (RequestCacheAwareFilter.java:63) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:334) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at ru.coffeetearea.security.jwt.JwtTokenFilter.doFilter (JwtTokenFilter.java:33) ~ [main /: na]
at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:334) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter (LogoutFilter.java:116) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:334) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter (HeaderWriterFilter.java:92) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal (HeaderWriterFilter.java:77) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:119) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:334) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter (SecurityContextPersistenceFilter.java:105) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:334) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
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]
at org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:119) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:334) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at org.springframework.security.web.FilterChainProxy.doFilterInternal (FilterChainProxy.java:215) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at org.springframework.security.web.FilterChainProxy.doFilter (FilterChainProxy.java:178) ~ [spring-security-web-5.3.3.RELEASE.jar: 5.3.3.RELEASE]
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate (DelegatingFilterProxy.java:358) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at org.springframework.web.filter.DelegatingFilterProxy.doFilter (DelegatingFilterProxy.java:271) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:193) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal (RequestContextFilter.java:100) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:119) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:193) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.springframework.web.filter.FormContentFilter.doFilterInternal (FormContentFilter.java:93) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:119) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:193) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal (CharacterEncodingFilter.java:201) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:119) ~ [spring-web-5.2.7.RELEASE.jar: 5.2.7.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:193) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.apache.catalina.core.StandardWrapperValve.invoke (StandardWrapperValve.java:202) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.apache.catalina.core.StandardContextValve.invoke (StandardContextValve.java:96) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke (AuthenticatorBase.java:541) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.apache.catalina.core.StandardHostValve.invoke (StandardHostValve.java:139) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java: 92) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.apache.catalina.core.StandardEngineValve.invoke (StandardEngineValve.java:74) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.apache.catalina.connector.CoyoteAdapter.service (CoyoteAdapter.java:343) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.apache.coyote.http11.Http11Processor.service (Http11Processor.java:373) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.apache.coyote.AbstractProcessorLight.process (AbstractProcessorLight.java:65) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.apache.coyote.AbstractProtocol $ ConnectionHandler.process (AbstractProtocol.java:868) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun (NioEndpoint.java:1590) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at org.apache.tomcat.util.net.SocketProcessorBase.run (SocketProcessorBase.java:49) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
at java.base / java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128) ~ [na: na]
at java.base / java.util.concurrent.ThreadPoolExecutor $ Worker.run (ThreadPoolExecutor.java:628) ~ [na: na]
at org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run (TaskThread.java:61) ~ [tomcat-embed-core-9.0.36.jar: 9.0.36]
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)调用字段。

@Formula("coalesce((select sum(c.count) from cart_items c" +
            " left join pg_order po on c.order_id = po.id" +
            " where po.order_status = 'ACTIVE' and\n" +
            "c.drink_id = id), 0)")
    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).

@Formula("coalesce((select sum(c.count) from cart_items c" +
            " left join pg_order po on c.order_id = po.id" +
            " where po.order_status = 'ACTIVE' and\n" +
            "c.drink_id = id), 0)")
    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:

确定