首页 > 解决方案 > 如何修复错误“无法构建 Hibernate SessionFactory”列错误?

问题描述

我试图在 Hibernate 中对我的数据库表进行左外连接,但是我一直遇到同样的错误。什么都不会运行,我一直在尝试找出解决方案一段时间。如果有人有任何在线教程或任何我可以找到可能的解决方案的地方,我会全力以赴。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: mapped, for columns: [org.hibernate.mapping.Column(avs_application)]

我相信从错误中它与我有关set<AVSApplication>,但我无法弄清楚错误在代码中的位置。

AVS应用:

@Entity
@Table(name = "avs")
public class AVSApplication implements java.io.Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    @Id
    @Column(name = "appcode")
    private String appcode;

    @Column(name = "acro")
    private String acro;

    @Column(name = "appname")
    private String appname;

    private AVSMapped avsMapped;


    //Constructor
    public AVSApplication(String mAppCode, String mAcronym, String mAppName) {
        super();
        this.appcode = mAppCode;
        this.acro = mAcronym;
        this.appname = mAppName;

    }


    //Default Constructor
    public AVSApplication () {

    }


    //Getters
    public String getmAppCode() {
        return appcode;
    }

    public String getmAcronym() {
        return acro;
    }
    public String getmAppName() {
        return appname;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "mGpStatus")
    public AVSMapped getMapped() {
        return avsMapped;
    }




    //Setters
    public void setmAcronym(String mAcronym) {
        this.acro = mAcronym;
    }

    public void setmAppCode(String mAppCode) {
        this.appcode = mAppCode;
    }

    public void setmAppName(String mAppName) {
        this.appname = mAppName;
    }

    public void setMapped(AVSMapped avsMapped) {
        this.avsMapped = avsMapped;
    }

AV映射:

@Entity
@Table(name = "mapped")
public class AVSMapped implements java.io.Serializable  {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    @Id
    @Column(name = "mAppcode")
    private String mAppcode;

    @Column(name = "mAcro")
    private String mAcro;

    @Column(name = "mAppname")
    private String mAppname;

    @Column(name = "mGpStatus")
    private String mGpStatus;

    private Set<AVSApplication> avsApplication = new HashSet<AVSApplication>();


    //Constructor
    public AVSMapped(String mAppCode, String mAcronym, String mAppName, String mGpStatus) {
        super();
        this.mAppcode = mAppCode;
        this.mAcro = mAcronym;
        this.mAppname = mAppName;
        this.mGpStatus = mGpStatus;

    }


    //Default Constructor
    public AVSMapped () {

    }


    //Getters
    public String getmAppCode() {
        return mAppcode;
    }

    public String getmAcronym() {
        return mAcro;
    }
    public String getmAppName() {
        return mAppname;
    }
    public String getmGpStatus() {
        return mGpStatus;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "mapped")
    public Set<AVSApplication> getProducts() {
        return this.avsApplication;
    }





    //Setters
    public void setmAcronym(String mAcronym) {
        this.mAcro = mAcronym;
    }

    public void setmAppCode(String mAppCode) {
        this.mAppcode = mAppCode;
    }

    public void setmAppName(String mAppName) {
        this.mAppname = mAppName;
    }

    public void setmGpStatus(String mGpStatus) {
        this.mGpStatus = mGpStatus;
    }

    public void setProducts(Set<AVSApplication> app) {
        this.avsApplication = app;
    }


DTO:

public class ApplicationDTO implements java.io.Serializable {


    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private String dtoAppCode;
    private String dtoAcro;
    private String dtoAppName;
    private String dtoGpStatus;

    //Constructor
    public ApplicationDTO(String dtoAppCode, String dtoAcro, String dtoAppName, String dtoGpStatus) {
        super();
        this.dtoAppCode = dtoAppCode;
        this.dtoAcro = dtoAcro;
        this.dtoAppName = dtoAppName;
        this.dtoGpStatus = dtoGpStatus;

    }


    //Default Constructor
    public ApplicationDTO(){

    }


    //Getters
    public String getDtoAppCode() {
        return dtoAppCode;
    }

    public String getDtoAcro() {
        return dtoAcro;
    }

    public String getDtoGpStatus() {
        return dtoGpStatus;
    }

    public String getDtoAppName() {
        return dtoAppName;
    }



    //Setters
    public void setDtoAppName(String dtoAppName) {
        this.dtoAppName = dtoAppName;
    }

    public void setDtoAcro(String dtoAcro) {
        this.dtoAcro = dtoAcro;
    }

    public void setDtoAppCode(String dtoAppCode) {
        this.dtoAppCode = dtoAppCode;
    }


    public void setDtoGpStatus(String dtoGpStatus) {
        this.dtoGpStatus = dtoGpStatus;
    }

应用程序:

@Repository("appRepository")
public interface AppRepository extends JpaRepository<AVSApplication, String>{

    @Query("select new com.UPS.model.ApplicationDTO(p.appcode, p.acro, p.appname, p.avsMapped.mAppcode) from AVSApplication p, AVSMapped c where p.appcode = c.mAppcode")
    public List<ApplicationDTO> join();



}

标签: javaspringhibernate

解决方案


推荐阅读