如何修复错误“无法构建Hibernate SessionFactory”列错误?

时间:2019-10-14 16:03:24

标签: java spring hibernate

我正在尝试在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>有关,但是我无法弄清楚错误在哪里。

AVSApplication:

@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;
    }

AVSMapped:

@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();



}

0 个答案:

没有答案