Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hibernate 弹簧靴&x2B;冬眠+;JPA=使用存储库的命名oracle过程调用失败_Hibernate_Spring Boot_Jpa - Fatal编程技术网

Hibernate 弹簧靴&x2B;冬眠+;JPA=使用存储库的命名oracle过程调用失败

Hibernate 弹簧靴&x2B;冬眠+;JPA=使用存储库的命名oracle过程调用失败,hibernate,spring-boot,jpa,Hibernate,Spring Boot,Jpa,我想知道为什么: 使用repo失败,而使用EntityManager工作正常 “org.hibernate.procedure.ParameterStrategyException:尝试访问位置参数[1],但在将唯一的参数命名后抛出“使用命名参数调用ProcedureCall”(将“name=“po_list”添加到@StoredProcedureParameter,将“outputParameterName=“po_list”添加到@procedure) 在没有结果的情况下尝试: 替换“res

我想知道为什么:

  • 使用repo失败,而使用EntityManager工作正常
  • “org.hibernate.procedure.ParameterStrategyException:尝试访问位置参数[1],但在将唯一的参数命名后抛出“使用命名参数调用ProcedureCall”(将“name=“po_list”添加到@StoredProcedureParameter,将“outputParameterName=“po_list”添加到@procedure)
  • 在没有结果的情况下尝试:

  • 替换“resultClasses=ReferenceInsurance.class”
  • 将“type=void.class”替换为“type=class.class”,并替换为“type=ReferenceInsurance.class”
  • 应用程序:

    package org.nyulmc.db;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.context.annotation.Bean;
    import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
    
    import javax.persistence.EntityManager;
    import java.util.List;
    
    @SpringBootApplication(scanBasePackages = "org.nyulmc.db")
    @EnableJpaRepositories(basePackages = "org.nyulmc.db")
    @EnableAutoConfiguration
    public class DbPackageOnly {
    
        @Bean
        public Object usingEntityManager(EntityManager em) {
            final List<ReferenceInsurance> list = em.createNamedStoredProcedureQuery("getRefEpicWebListNew").getResultList();
            return list;
        }
    
        @Bean
        public Object usingRepo(Repo repo) {
            final List<ReferenceInsurance> refEpicWebListNew = repo.getRefEpicWebListNew();
            return refEpicWebListNew;
        }
    
        public static void main(String[] args) {
            SpringApplication springApplication = new SpringApplication(DbPackageOnly.class);
            springApplication.setAdditionalProfiles("ora_dev");
            springApplication.run(args);
        }
    
    }
    
    Oracle过程签名:

    PROCEDURE get_RefEpicWebListNew(po_list OUT mycursor)
    
    回购:

    plugins {
        id "io.spring.dependency-management" version "1.0.9.RELEASE"
        id 'org.springframework.boot' version '2.0.9.RELEASE'
        ...
    }
    dependencies {
        implementation('org.springframework.boot:spring-boot-starter-data-jpa')
        ...
    }
    
    PROCEDURE get_RefEpicWebListNew(po_list OUT mycursor)
    
    package org.nyulmc.db;
    
    import org.springframework.data.jpa.repository.query.Procedure;
    import org.springframework.data.repository.Repository;
    
    import javax.transaction.Transactional;
    import java.util.List;
    
    
    public interface Repo extends Repository<ReferenceInsurance, Long> {
    
        @Transactional
        @Procedure(name = "getRefEpicWebListNew")
        List<ReferenceInsurance> getRefEpicWebListNew();
    
    }
    
    
    package org.nyulmc.db;
    
    import javax.persistence.*;
    
    @NamedStoredProcedureQueries({
            @NamedStoredProcedureQuery(
                    name = "getRefEpicWebListNew",
                    procedureName = "DTIPDUSER.PD_REF_PKG.get_RefEpicWebListNew",
                    resultClasses = ReferenceInsurance.class,
                    parameters = {
                            @StoredProcedureParameter(mode = ParameterMode.REF_CURSOR, type = void.class)
                    }
            )})
    @Entity
    public class ReferenceInsurance {
    
        @Id
        @Column(name = "benefit_plan_id")
        private Long benefitPlanId;
    
        @Column(name = "display_plan_name")
        private String displayPlanName;
    
        public Long getBenefitPlanId() {
            return benefitPlanId;
        }
    
        public void setBenefitPlanId(Long benefitPlanId) {
            this.benefitPlanId = benefitPlanId;
        }
    
        public String getDisplayPlanName() {
            return displayPlanName;
        }
    
        public void setDisplayPlanName(String displayPlanName) {
            this.displayPlanName = displayPlanName;
        }
    
    }