hibernate / hibernate-reactive

A reactive API for Hibernate ORM, supporting non-blocking database drivers and a reactive style of interaction with the database.
https://hibernate.org/reactive
Apache License 2.0
440 stars 92 forks source link

Could not resolve specified result-set mapping name #1618

Closed abhijitdash closed 1 year ago

abhijitdash commented 1 year ago

Hi, I am trying have migrated to springboot 3.0.1 and my application is running fine but when i am hitting the endpoint, i am getting this error Hibernate: select Count(*) from hercules_forecast_vw WHERE source_system = ? 2023-05-09T10:36:53.554+05:30 ERROR 13708 --- [nio-8082-exec-8] o.a.c.c.C.[.[.[.[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [/cascca/bapi] threw exception [Request processing failed: jakarta.persistence.PersistenceException: Convertingorg.hibernate.HibernateExceptionto JPAPersistenceException` : Could not resolve specified result-set mapping name : herculesforecast] with root cause

org.hibernate.HibernateException: Could not resolve specified result-set mapping name : herculesforecast at org.hibernate.internal.AbstractSharedSessionContract.createNativeQuery(AbstractSharedSessionContract.java:801) ~[hibernate-core-6.1.4.Final.jar:6.1.4.Final] at org.hibernate.internal.AbstractSharedSessionContract.createNativeQuery(AbstractSharedSessionContract.java:127) ~[hibernate-core-6.1.4.Final.jar:6.1.4.Final] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[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:568) ~[na:na] at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:360) ~[spring-orm-6.0.3.jar:6.0.3] at jdk.proxy2/jdk.proxy2.$Proxy152.createNativeQuery(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:77) ~[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:568) ~[na:na] at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:307) ~[spring-orm-6.0.3.jar:6.0.3] at jdk.proxy2/jdk.proxy2.$Proxy152.createNativeQuery(Unknown Source) ~[na:na] at com.cargill.api.casc.service.jarvis.repository.JarvisRepo.getQueryResponse(JarvisRepo.java:67) ~[classes/:na] at com.cargill.api.casc.service.jarvis.service.JarvisService.getResponse(JarvisService.java:94) ~[classes/:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[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:568) ~[na:na] at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) ~[spring-aop-6.0.8.jar:6.0.8] at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698) ~[spring-aop-6.0.8.jar:6.0.8] at com.cargill.api.casc.service.jarvis.service.JarvisService$$SpringCGLIB$$0.getResponse() ~[classes/:na] at com.cargill.api.casc.service.jarvis.controller.MSController.getHerculesForecast(MSController.java:389) ~[classes/:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[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:568) ~[na:na] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:207) ~[spring-web-6.0.3.jar:6.0.3] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:152) ~[spring-web-6.0.3.jar:6.0.3] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-6.0.3.jar:6.0.3] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:884) ~[spring-webmvc-6.0.3.jar:6.0.3] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797) ~[spring-webmvc-6.0.3.jar:6.0.3] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-6.0.3.jar:6.0.3] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1080) ~[spring-webmvc-6.0.3.jar:6.0.3] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:973) ~[spring-webmvc-6.0.3.jar:6.0.3] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1010) ~[spring-webmvc-6.0.3.jar:6.0.3] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:902) ~[spring-webmvc-6.0.3.jar:6.0.3] at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:564) ~[tomcat-embed-core-10.1.8.jar:6.0] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:884) ~[spring-webmvc-6.0.3.jar:6.0.3] at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658) ~[tomcat-embed-core-10.1.8.jar:6.0] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) ~[tomcat-embed-websocket-10.1.8.jar:10.1.8] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-6.0.3.jar:6.0.3] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.3.jar:6.0.3] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-6.0.3.jar:6.0.3] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.3.jar:6.0.3] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.springframework.web.filter.ServerHttpObservationFilter.doFilterInternal(ServerHttpObservationFilter.java:109) ~[spring-web-6.0.3.jar:6.0.3] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.0.3.jar:6.0.3] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:166) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:341) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:390) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:894) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1741) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-10.1.8.jar:10.1.8] at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na] `

pom.xml..... `<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>com.cargill.api.casc</groupId>
<artifactId>bsapi-casc-e2e-port-optimzation-jarvis</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>bsapi-casc-e2e-port-optimzation-jarvis</name>
<description>port optimzation data API for Canada</description>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.0.1</version>
</parent>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>17</java.version>
    <HikariCP.version>3.3.0</HikariCP.version>
    <maven.compiler.source>${java.version}</maven.compiler.source>
    <maven.compiler.target>${java.version}</maven.compiler.target>
    <maven.jar.plugin.version>3.1.0</maven.jar.plugin.version>
    <maven.resource.plugin.version>3.1.0</maven.resource.plugin.version>
    <cglib.version>3.2.6</cglib.version>
    <junit.jupiter.version>5.4.2</junit.jupiter.version>
    <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
    <sonar.language>java</sonar.language>
    <impala.jdbc.version>2.5.38</impala.jdbc.version>
    <org.postgresql>42.2.14</org.postgresql>
    <org.modelmapper>2.3.7</org.modelmapper>
    <datasource-proxy.version>1.6</datasource-proxy.version>
    <org.apache.commons.lang.version>3.4</org.apache.commons.lang.version>
    <apache.thrift.version>0.14.1</apache.thrift.version>
    <com.google.code.gson>2.8.6</com.google.code.gson>
    <httpclient.version>4.5.13</httpclient.version>
    <snakeyaml.version>2.0</snakeyaml.version>
    <tomcat-annotations-api.version>10.0.2</tomcat-annotations-api.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.hibernate.orm</groupId>
                <artifactId>hibernate-core</artifactId>
            </exclusion>
            <exclusion>
                <artifactId>dom4j</artifactId>
                <groupId>org.dom4j</groupId>
            </exclusion>
            <exclusion>
                <groupId>com.zaxxer</groupId>
                <artifactId>HikariCP</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
    </dependency>
    <dependency>
        <groupId>com.zaxxer</groupId>
        <artifactId>HikariCP</artifactId>
        <version>3.3.0</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate.orm</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>6.1.4.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate.common</groupId>
        <artifactId>hibernate-commons-annotations</artifactId>
        <version>6.0.6.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate.validator</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>8.0.0.Final</version>
    </dependency>
    <dependency>
        <groupId>jakarta.el</groupId>
        <artifactId>jakarta.el-api</artifactId>
        <version>5.0.0</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <version>3.0.1</version>
        <exclusions>
            <exclusion>
                <groupId>org.apache.tomcat.embed</groupId>
                <artifactId>tomcat-embed-core</artifactId>
            </exclusion>
            <!--                <exclusion>-->
            <!--                    <groupId>org.apache.tomcat.embed</groupId>-->
            <!--                    <artifactId>tomcat-embed-el</artifactId>-->
            <!--                </exclusion>-->
            <exclusion>
                <groupId>org.apache.tomcat.embed</groupId>
                <artifactId>tomcat-embed-websocket</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-websocket</artifactId>
        <version>10.1.8</version>
        <exclusions>
            <exclusion>
                <groupId>org.apache.tomcat.embed</groupId>
                <artifactId>tomcat-embed-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-core</artifactId>
        <version>10.1.8</version>
        <exclusions>
            <exclusion>
                <groupId>org.apache.tomcat</groupId>
                <artifactId>tomcat-annotations-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>net.ttddyy</groupId>
        <artifactId>datasource-proxy</artifactId>
        <version>${datasource-proxy.version}</version>
    </dependency>
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk-s3</artifactId>
        <version>1.12.445</version>
        <exclusions>
            <exclusion>
                <groupId>com.fasterxml.jackson.dataformat</groupId>
                <artifactId>jackson-dataformat-cbor</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.dataformat</groupId>
        <artifactId>jackson-dataformat-yaml</artifactId>
        <version>2.15.0</version>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>${com.google.code.gson}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>6.0.3</version>
        <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-commons</artifactId>
        <version>1.8.2</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-jpa</artifactId>
        <version>3.0.1</version>
        <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-launcher</artifactId>
        <version>1.8.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>jakarta.persistence</groupId>
        <artifactId>jakarta.persistence-api</artifactId>
        <version>3.1.0</version>
    </dependency>
    <dependency>
        <groupId>jakarta.servlet</groupId>
        <artifactId>jakarta.servlet-api</artifactId>
        <version>6.0.0</version>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter</artifactId>
        <version>${junit.jupiter.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.14.2</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.14.2</version>
    </dependency>

    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20220320</version>
    </dependency>
    <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt-api</artifactId>
        <version>0.11.5</version>
    </dependency>
    <dependency>
        <groupId>io.dropwizard.metrics</groupId>
        <artifactId>metrics-core</artifactId>
    </dependency>
    <dependency>
        <groupId>com.timgroup</groupId>
        <artifactId>java-statsd-client</artifactId>
        <version>3.1.0</version>
    </dependency>
    <dependency>
        <groupId>com.datadoghq</groupId>
        <artifactId>dd-trace-api</artifactId>
        <version>1.11.2</version>
    </dependency>

    <dependency>
        <groupId>org.sonarsource.java</groupId>
        <artifactId>sonar-jacoco-listeners</artifactId>
        <version>5.14.0.18788</version>
    </dependency>

    <dependency>
        <groupId>com.openpojo</groupId>
        <artifactId>openpojo</artifactId>
        <version>0.9.0</version>
    </dependency>

    <dependency>
        <groupId>org.dom4j</groupId>
        <artifactId>dom4j</artifactId>
        <version>2.1.4</version>
    </dependency>

    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.24</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>${org.postgresql}</version>
    </dependency>
    <dependency>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-core</artifactId>
        <version>9.15.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.thrift</groupId>
        <artifactId>libthrift</artifactId>
        <version>${apache.thrift.version}</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-dynamodb -->
    <dependency>
        <groupId>com.fasterxml.jackson.dataformat</groupId>
        <artifactId>jackson-dataformat-cbor</artifactId>
        <version>2.15.0-rc1</version>
    </dependency>
    <!-- CDP Impala JDBC -->
    <dependency>
        <groupId>com.cloudera.impala.jdbc</groupId>
        <artifactId>ImpalaJDBC41</artifactId>
        <version>${impala.jdbc.version}</version>
    </dependency>
    <dependency>
        <groupId>com.cloudera.impala.jdbc</groupId>
        <artifactId>hive_metastore</artifactId>
        <version>${impala.jdbc.version}</version>
    </dependency>
    <dependency>
        <groupId>com.cloudera.impala.jdbc</groupId>
        <artifactId>hive_service</artifactId>
        <version>${impala.jdbc.version}</version>
    </dependency>
    <dependency>
        <groupId>com.cloudera.impala.jdbc</groupId>
        <artifactId>ql</artifactId>
        <version>${impala.jdbc.version}</version>
    </dependency>
    <dependency>
        <groupId>com.cloudera.impala.jdbc</groupId>
        <artifactId>TCLIServiceClient</artifactId>
        <version>${impala.jdbc.version}</version>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>2.1.210</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>6.0.8</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>6.0.8</version>
        <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-properties-migrator</artifactId>
        <scope>runtime</scope>
    </dependency>
    <!-- Apache Commons -->
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>${org.apache.commons.lang.version}</version>
    </dependency>
    <!-- Test Dependencies -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
        <exclusions>
            <!--  <exclusion>
                <groupId> junit</groupId>
                <artifactId> junit</artifactId>
              </exclusion>-->
            <exclusion>
                <groupId>com.vaadin.external.google</groupId>
                <artifactId>android-json</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
            </exclusion>

            <exclusion>
                <groupId>org.junit.vintage</groupId>
                <artifactId>junit-vintage-engine</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springdoc</groupId>
        <artifactId>springdoc-openapi-ui</artifactId>
        <version>1.6.15</version>
    </dependency>
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.11.0</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <jmxPort>9011</jmxPort>
                <classifier>bootified</classifier>
                <finalName>${project.artifactId}</finalName>
                <excludes>
                    <exclude>
                        <groupId>com.google.guava</groupId>
                        <artifactId>guava</artifactId>
                    </exclude>
                    <exclude>
                        <groupId>commons-collections</groupId>
                        <artifactId>commons-collections</artifactId>
                        <!-- <version>3.2.1</version> -->
                    </exclude>
                </excludes>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <archive>
                    <addMavenDescriptor>false</addMavenDescriptor>
                    <manifestEntries>
                        <Bsapi-CASC-paymentsna-Version>${project.version}</Bsapi-CASC-paymentsna-Version>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <skipTests>false</skipTests>
                <testFailureIgnore>true</testFailureIgnore>
                <forkMode>once</forkMode>
                <properties>
                    <property>
                        <name>listener</name>
                        <value>org.sonar.java.jacoco.JUnitListener</value>
                    </property>
                </properties>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.10.1</version>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>3.0.0</version>
        </plugin>
        <plugin>
            <groupId>org.sonarsource.scanner.maven</groupId>
            <artifactId>sonar-maven-plugin</artifactId>
            <version>3.8.0.2131</version>
        </plugin>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.8.8</version>
            <executions>
                <execution>
                    <id>prepare-agent</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <execution>
                    <id>report</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
                <execution>
                    <id>post-unit-test</id>
                    <phase>test</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                    <configuration>
                        <!-- Sets the path to the file which contains the execution data. -->

                        <dataFile>target/jacoco.exec</dataFile>
                        <!-- Sets the output directory for the code coverage report. -->
                        <outputDirectory>target/jacoco-ut</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <!--                      <excludes>-->
            <!--                              <exclude>application.yaml</exclude>-->
            <!--                          </excludes>-->
        </resource>
    </resources>
</build>

`

Annotation class: `package com.cargill.api.casc.service.jarvis.model;

import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; import lombok.ToString;

import jakarta.persistence.ColumnResult; import jakarta.persistence.ConstructorResult; import jakarta.persistence.MappedSuperclass; import jakarta.persistence.SqlResultSetMapping;

@ToString @NoArgsConstructor @AllArgsConstructor @MappedSuperclass @SqlResultSetMapping(name = "herculesforecast", classes = { @ConstructorResult(targetClass = HerculesForecast.class, columns = { @ColumnResult(name = "source_system", type = String.class), @ColumnResult(name = "week", type = String.class), @ColumnResult(name = "cycle", type = String.class), @ColumnResult(name = "terminal", type = String.class), @ColumnResult(name = "corridor", type = String.class), @ColumnResult(name = "commodity", type = String.class), @ColumnResult(name = "forecast_year", type = Integer.class), @ColumnResult(name = "forecast_month", type = Integer.class), @ColumnResult(name = "first_day_of_month", type = String.class), @ColumnResult(name = "is_current_cycle", type = Integer.class), @ColumnResult(name = "capacity", type = Double.class), @ColumnResult(name = "budget_volume", type = Double.class), @ColumnResult(name = "sales_forecast", type = Double.class), @ColumnResult(name = "location_shipping_forecast", type = Double.class), @ColumnResult(name = "roll_previous_month", type = Double.class), @ColumnResult(name = "total_sold", type = Double.class), @ColumnResult(name = "total_sold_roll_in", type = Double.class), @ColumnResult(name = "shipped_in_month", type = Double.class), @ColumnResult(name = "sales_rolled_next_month", type = Double.class), @ColumnResult(name = "left_to_ship", type = Double.class), @ColumnResult(name = "unsold_allocated_capacity", type = Double.class), @ColumnResult(name = "unallocated_capacity", type = Double.class), @ColumnResult(name = "unshipped_capacity", type = Double.class), @ColumnResult(name = "previous_3_months_forecast", type = Double.class), @ColumnResult(name = "forecast_accuracy", type = Double.class), @ColumnResult(name = "total_unsold", type = Double.class), @ColumnResult(name = "total_projected_shipments", type = Double.class), @ColumnResult(name = "initial_inventory", type = Double.class), @ColumnResult(name = "total_inbounds", type = Double.class), @ColumnResult(name = "last_year_shipped_in_month", type = Double.class), @ColumnResult(name = "fiscal_year", type = String.class),

    }) })

public class HerculesForecast {

@JsonProperty("source_system")
private String sourceSystem;

@JsonProperty("week")
private String week;

@JsonProperty("cycle")
private String cycle;

@JsonProperty("terminal")
private String terminal;

@JsonProperty("corridor")
private String corridor;

@JsonProperty("commodity")
private String commodity;

@JsonProperty("forecast_year")
private Integer forecastYear;

@JsonProperty("forecast_month")
private Integer forecastMonth;

@JsonProperty("first_day_of_month")
private String firstDayOfMonth;

@JsonProperty("is_current_cycle")
private Integer isCurrentCycle;

@JsonProperty("capacity")
private Double capacity;

@JsonProperty("budget_volume")
private Double budgetVolume;

@JsonProperty("sales_forecast")
private Double salesForecast;

@JsonProperty("location_shipping_forecast")
private Double locationShippingForecast;

@JsonProperty("roll_previous_month")
private Double rollPreviousMonth;

@JsonProperty("total_sold")
private Double totalSold;

@JsonProperty("total_sold_roll_in")
private Double totalSoldRollIn;

@JsonProperty("shipped_in_month")
private Double shippedInMonth;

@JsonProperty("sales_rolled_next_month")
private Double salesRolled_next_month;

@JsonProperty("left_to_ship")
private Double leftToShip;

@JsonProperty("unsold_allocated_capacity")
private Double unsoldAllocatedCapacity;

@JsonProperty("unallocated_capacity")
private Double unallocatedCapacity;

@JsonProperty("unshipped_capacity")
private Double unshippedCapacity;

@JsonProperty("previous_3_months_forecast")
private Double previous3MonthsForecast;

@JsonProperty("forecast_accuracy")
private Double forecastAccuracy;

@JsonProperty("total_unsold")
private Double totalUnsold;

@JsonProperty("total_projected_shipments")
private Double totalProjectedShipments;

@JsonProperty("initial_inventory")
private Double initialInventory;

@JsonProperty("total_inbounds")
private Double totalInbounds;

@JsonProperty("last_year_shipped_in_month")
private Double lastYearShippedInMonth;

@JsonProperty("fiscal_year")
private String fiscalYear;

} `

creating native query..... `package com.cargill.api.casc.service.jarvis.repository;

import com.cargill.api.casc.service.jarvis.util.JarvisUtil; import jakarta.persistence.EntityManager; import jakarta.persistence.Query; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component;

import java.util.HashMap; import java.util.List; import java.util.Map;

//@Primary @Component("jarvisrepo") public class JarvisRepo {

@Autowired
private JarvisUtil jarvisUtil;

@Autowired
@Qualifier(value = "mainEntityManager")
private EntityManager em;

@Value("#{${jarvis.whereClause.map}}")
Map<String, String> whereClauseMap;

@Value("#{${jarvis.table.map}}")
Map<String, String> tableMap;

@Value("#{${jarvis.query.map}}")
Map<String, String> queryMap;

@Value("#{${jarvis.orderBy.map}}")
Map<String, String> orderByMap;

@Value("#{${jarvis.groupBy.map}}")
Map<String, String> groupByMap;

@Value("#{${jarvis.custom.map}}")
Map<String, String> customMap;

private String getLimitOffsetQueryString() {
    return " limit :limit offset :offset";
}

public <T> List<T> getQueryResponse(Map<String, Object> paramMap, Integer limit, Integer offset, String baseTableName) {

    StringBuilder selectQuery = new StringBuilder();
    Map<String, Object> queryParamMap = new HashMap<>();
    StringBuilder whereQueryString = new StringBuilder();
    selectQuery.append(queryMap.get(baseTableName));
    whereQueryString = jarvisUtil.addWhereCaluse(paramMap, queryParamMap, whereQueryString, whereClauseMap);
    if(customMap.containsKey(baseTableName)) {
        whereQueryString.append(customMap.get(baseTableName));
    }
    if(groupByMap.containsKey(baseTableName)){
        whereQueryString.append(groupByMap.get(baseTableName));
    }
    whereQueryString.append(orderByMap.get(baseTableName)).append(getLimitOffsetQueryString());
    if (whereQueryString.length() > 0) {
        selectQuery.append(" WHERE ");
        selectQuery.append(whereQueryString);
    }

    Query query = em.createNativeQuery(selectQuery.toString(), baseTableName);
    addParamForOffsetLimit(queryParamMap, offset, limit);
    queryParamMap.forEach((key, value) -> {
        query.setParameter(key, value);
    });
    return query.getResultList();
}

public List<Object[]> getTableCount(Map<String, Object> paramMap,String table) {
    StringBuilder routeRateCount = new StringBuilder();
    Map<String, Object> queryParamMap = new HashMap<>();
    StringBuilder whereQueryString = new StringBuilder();
    routeRateCount.append("select Count(*)  from ").append(tableMap.get(table));
    whereQueryString = jarvisUtil.addWhereCaluse(paramMap, queryParamMap, whereQueryString, whereClauseMap);
    if (whereQueryString.length() > 0) {
        routeRateCount.append(" WHERE ");
        routeRateCount.append(whereQueryString);
    }
    if(customMap.containsKey(table)) {
        routeRateCount.append(customMap.get(table));
    }
    Query query = em.createNativeQuery(routeRateCount.toString());
    queryParamMap.forEach((key, value) -> {
        query.setParameter(key, value);
    });
    return query.getResultList();
}

private Map<String, Object> addParamForOffsetLimit(Map<String, Object> map, Integer offset, Integer limit) {
    map.put("limit", limit);
    map.put("offset", offset);
    return map;
}

} `

DavideD commented 1 year ago

This is not the right repository, this is Hibernate Reactive and you are using Hibernate ORM. You can open an issue here instead.