错误java代码eclipse SQL错误:972,SQLState:42000 ORA-00972:标识符太长

时间:2018-04-25 16:34:05

标签: java spring spring-boot

我收到错误 SQL错误:972,SQLState:42000 ORA-00972:标识符太长

以下是我的代码:

package com.example.demo;

import java.util.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import com.example.demo.dao.Pharmacyservice;
import com.example.demo.model.Pharmacy;

@SpringBootApplication

public class DemoApplication implements CommandLineRunner {

    @Autowired
    Pharmacyservice pharmacyservice;

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        getPharmacy();
    }

    private void getPharmacy() {        
        /*Pharmacy ph = new Pharmacy();*/       
        /*ph.setPharmacyIdentifier(2);*/
        Iterable<Pharmacyphs=new ArrayList<>();
        /*Optional <Pharmacy> phs =Optional.of(ph);*/

        phs = pharmacyservice.getPharmacy(2);
        System.out.println(phs);
    }
}

-

package com.example.demo.dao;

import java.util.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.example.demo.model.Pharmacy;

@Service
public class Pharmacyservice {
    @Autowired
    PharmacyImpl pharmacyImpl;
    public Iterable<Pharmacy> getPharmacy(Integer id) {
        return pharmacyImpl.findAll();

    }


}

public interface PharmacyImpl extends CrudRepository<Pharmacy, Integer> {

}

@Component
@Entity
@Table(name="PHARMACY",schema="cf_7a96116e_afac_4e08_b6d8_2492a89d5652")
public class Pharmacy {

    @Id
    @Column(name="PHARMACY_IDENTITY")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer pharmacyIdentifier;

    @Column(name="PHMCY_ID")
    private String pharmacyId;

    @Column(name="DAT_SRC_ID")
    private String dataSourceId;

    @Column(name="SRC_PHMCY_ID")
    private String sourcePharmacyId;

    @Column(name="PHMCY_CORP_ID")
    private String pharmacyCorpId;

    @Column(name="PHMCY_NM")
    private String pharmacyName;

    @Column(name="PHMCY_ADDR_LINE1_TX")
    private String addressLine1Text;

    @Column(name="PHMCY_ADDR_LINE2_TX")
    private String addressLine2Text;

    @Column(name="PHMCY_ADDR_LINE3_TX")
    private String addressLine3Text;

    @Column(name="PHMCY_CITY_TX")
    private String pharmacyCityText;

    @Column(name="CNTY_TX")
    private String countyText;

    @Column(name="PHMCY_ST_CD")
    private String pharmacyStateCode;

    @Column(name="PHMCY_ZIP_CD")
    private String pharmacyZipCode;

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

    @Column(name="BILL_FAX_NB")
    private String billFaxNumber;

    @Column(name="PHMCY_RGN_CD")
    private String pharmacyRegionCode;

    @Column(name="PHMCY_SRVC_TYP")
    private String pharmcyServiceType;

    @Column(name="DBA_NM")
    private String dbaName;

    @Column(name="DEA_NB")
    private String deaNumber;

    @Column(name="FAX_NB")
    private String faxNumber;

    @Column(name="LOCKBOX_NB")
    private String lockBoxNumber;

    @Column(name="NABP_NB")
    private String nabpNumber;

    @Column(name="NPI_NB")
    private String npiNumber;

    @Column(name="IST_LIC_NB")
    private String istLICNumber;

    @Column(name="PHMCY_STORE_NB")
    private Integer pharmacyStoreNumber;

    @Column(name="PHMCY_MGR_NM")
    private String pharmacyMgrName;

    @Column(name="RPH_IN_CHRG_ID")
    private String rphInchargeId;

    @Column(name="PHMCY_MEDB_LEGL_NM")
    private String pharmacyMedbLegalName;

    @Column(name="PHMCY_MEDB_TAX_ID")
    private String pharmacyMedbTaxId;

    @Column(name="RTRN_ALLW_IN")
    private String rtrnAllowIn;

    @Column(name="IS_CLOS_IN")
    private String isCloseIn;

    @Column(name="PHMCY_ACTV_IN")
    private String pharmacyActiveIn;

    @Column(name="CURR_REC_IN")
    private String currentRecIn;

}

正在生成的SQL查询:     选择         pharmacy0_.PHARMACY_IDENTITY为PHARMACY1_14_,         pharmacy0_.PHMCY_ADDR_LINE1_TX为PHMCY_AD2_14_,         pharmacy0_.PHMCY_ADDR_LINE2_TX为PHMCY_AD3_14_,         pharmacy0_.PHMCY_ADDR_LINE3_TX为PHMCY_AD4_14_,         pharmacy0_.BILL_FAX_NB为BILL_FAX5_14_,         pharmacy0_.CNTY_TX为CNTY_TX6_14_,         pharmacy0_.CURR_REC_IN为CURR_REC7_14_,         pharmacy0_.DAT_SRC_ID为DAT_SRC_8_14_,         pharmacy0_.DBA_NM为DBA_NM9_14_,         pharmacy0_.DEA_NB为DEA_NB10_14_,         pharmacy0_.FAX_NB为FAX_NB11_14_,         pharmacy0_.IS_CLOS_IN为IS_CLOS12_14_,         pharmacy0_.LOCKBOX_NB作为LOCKBOX13_14_,         pharmacy0_.NABP_NB为NABP_NB14_14_,         pharmacy0_.NPI_NB为NPI_NB15_14_,         pharmacy0_.PHMCY_ACTV_IN为PHMCY_A16_14_,         pharmacy0_.PHMCY_CITY_TX为PHMCY_C17_14_,         pharmacy0_.PHMCY_CORP_ID为PHMCY_C18_14_,         pharmacy0_.PHMCY_ID为PHMCY_I19_14_,         pharmacy0_.PHMCY_MEDB_LEGL_NM为PHMCY_M20_14_,         pharmacy0_.PHMCY_MEDB_TAX_ID为PHMCY_M21_14_,         pharmacy0_.PHMCY_MGR_NM为PHMCY_M22_14_,         pharmacy0_.PHMCY_NM为PHMCY_N23_14_,         pharmacy0_.PHMCY_RGN_CD为PHMCY_R24_14_,         pharmacy0_.PHMCY_ST_CD为PHMCY_S25_14_,         pharmacy0_.PHMCY_STORE_NB为PHMCY_S26_14_,         pharmacy0_.PHMCY_ZIP_CD为PHMCY_Z27_14_,         pharmacy0_.PHMCY_SRVC_TYP为PHMCY_S28_14_,         pharmacy0_.PHONE_NB为PHONE_N29_14_,         pharmacy0_.RPH_IN_CHRG_ID为RPH_IN_30_14_,         pharmacy0_.RTRN_ALLW_IN为RTRN_AL31_14_,         pharmacy0_.SRC_PHMCY_ID为SRC_PHM32_14_,         pharmacy0_.ST_LIC_NB为ST_LIC_33_14_     从         cf_bfd29943_914a_4174_9ba1_42146cdbf376PHARMACY pharmacy0_     哪里         pharmacy0_.PHARMACY_IDENTITY =?

我无法理解我做错了什么!请帮忙

1 个答案:

答案 0 :(得分:2)

我认为发生了什么:根据您的@Entity类,您有一个尝试在第一次运行时创建数据库模式的设置。

您正在使用Oracle(ORA例外),其中最大模式名称长度为30个字节(在Oracle 12.1及更低版本中),并且您的模式名称cf_7a96116e_afac_4e08_b6d8_2492a89d5652为39个字符,因此它太长。更改架构名称,然后重试。