找不到逻辑名称为finc_mdse_model_desgtr的列

时间:2018-07-24 20:15:32

标签: hibernate spring-boot jpa foreign-keys spring-data-jpa

看起来这是一个很受欢迎的问题,但我仍然不知道为什么

使用Spring Boot 2.0.3,jpa,hibernate,teradata

我能够从数据库生成pojo。如果重要的话,我正在使用Views,而不是Tables。所以这些对我来说是只读的。

Intellij具有自动完成功能,因此它将为我验证注释值。他们似乎都是正确的。 fs_veh_ident中确实有FINC_MDSE_MODEL_DESGTR

主表

@Entity
@Table(name = "FS_VEH_IDENT", schema = "VEHICLE360", catalog = "")
public class VehicleIdentity {
@Id
private String vehIdNbr;

@OneToMany(mappedBy = "vehicle", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<VehicleOption> vehicleOptions;

private String subVin;
private String squishVin;
private String vinModelYrNbr;
private String vinModlYrCd;

...

选项表

@Entity
@Table(name = "FS_VEH_OPTION_CFD", schema = "VEHICLE360", catalog = "")
public class VehicleOption {

@ManyToOne
@JoinColumn(name = "MDNSG_MODEL_DESGTR", referencedColumnName = "FINC_MDSE_MODEL_DESGTR", insertable = false, updatable = false)
private VehicleIdentity vehicle;

private String ctryCd;
private String langCd;
private String modelYrNbr;
private String gsmcMake;
private String gsmcModel;

@Id
private String mdnsgModelDesgtr;
private String optionCd;

...

错误说

Caused by: org.hibernate.MappingException: Unable to find column with logical name: FINC_MDSE_MODEL_DESGTR in org.hibernate.mapping.Table(vehicle360.fs_veh_ident) and its related supertables and secondary tables
at org.hibernate.cfg.Ejb3JoinColumn.checkReferencedColumnsType(Ejb3JoinColumn.java:832)
at org.hibernate.cfg.BinderHelper.createSyntheticPropertyReference(BinderHelper.java:244)
at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:101)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processEndOfQueue(InFlightMetadataCollectorImpl.java:1771)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processFkSecondPassesInOrder(InFlightMetadataCollectorImpl.java:1715)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1602)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:278)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:861)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:888)
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:57)

纯SQL

select option_cd as optioncode, 
        opt.consumer_ctgry_desc as categorydescription, 

        from vehicle360.fs_veh_option_cfd as opt 
        left join vehicle360.fs_veh_ident vi on opt.mdnsg_model_desgtr = vi.finc_mdse_model_desgtr 
        where vi.veh_id_nbr = :vin2

编辑1:

好像我在hibernate 5.2.17中遇到了某种错误-我看到某种方法试图将逻辑名映射到hibernate中的物理名称,我将referencedColumnName更改为fincMdseModelDesgtr(驼峰式),该死的东西起作用了!!

0 个答案:

没有答案