首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Hibernate mappedBy

Hibernate mappedBy
EN

Stack Overflow用户
提问于 2017-06-01 17:19:22
回答 1查看 75关注 0票数 0

请告诉我为什么我错误地链接了这些表。PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl停止信息: com.ecls.ARSTools.DAO.CertificateField.сertificate :正在清理连接池jdbc:oracle:thin:@ARS-PS-DEV:1521:ars Exception in thread "main“java.lang.ExceptionInInitializerError: Initial SessionFactory failedorg.hibernate.AnnotationException: mappedBy引用未知的目标实体属性: com.ecls.ARSTools.DAO.Certificate.certificateFields in com.ecls.ARSTools.Tools.HibernateSessionFactory.buildSessionFactory(HibernateSessionFactory.java:21) at mappedBy at com.ecls.ARSTools。Tools.HibernateSessionFactory.(HibernateSessionFactory.java:10) at com.ecls.ARSTools.Tools.ImplARS.(ImplARS.java:14) at ecls.temp.AppMain.main(AppMain.java:16)

代码语言:javascript
复制
   @Entity
    @Table(name= "CERTIFICATE")
    public class Certificate implements IAvailableID{
        @Id
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "cert_generator")
        @SequenceGenerator(name="cert_generator", sequenceName = "SWS_CERTIFICATE_ID", allocationSize=1)
        @Column(name = "ID")
        private Long id;

        @Column(name= "NAME", unique = true, nullable = false, length=50)
        private String name;

        @OneToMany(targetEntity=CertificateField.class, mappedBy = "сertificate", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
        private List<CertificateField> certificateFields=new ArrayList<CertificateField>();

        public Certificate() {
            super();
        }

        public Certificate(String name, List<CertificateField> certificateFields) {
            super();
            this.name = name;
            this.certificateFields = certificateFields;
        }

        public Long getId() {
            return id;
        }
        public void setId(Long id) {
            this.id = id;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }

        public List<CertificateField> getCertificateFields() {
            return certificateFields;
        }

        public void setCertificateFields(List<CertificateField> certificateFields) {
            this.certificateFields = certificateFields;
        }

        @Override
        public String toString() {
            String res;
            res="-------------------\n";
            res+="Certificate [id=" + id + ", name=" + name+"]\n";
            for(CertificateField item:certificateFields){
                res+=item.toString()+"\n";
            }   
            return res;
        }   
    }


@Entity
@Table(name= "CERTIFICATE_FIELD")
public class CertificateField implements IAvailableID{
    @Id
    @Column(name= "ID")
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(name= "NAME", nullable = false, length=50)
    private String name;    

    @Column(name= "VALUE", nullable = false, length=50)
    private String value;   

    @ManyToOne(targetEntity=Certificate.class, cascade = CascadeType.ALL,fetch = FetchType.LAZY)
    @JoinColumn(name = "CERTIFICATE_ID", referencedColumnName="ID", nullable = false)
    private Certificate certificate;    

    public CertificateField(){
        super();
    }

    public CertificateField(String name, String value, Certificate certificate) {
        super();
        this.name = name;
        this.value = value;
        this.certificate = certificate;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }


    public Certificate getCertificate() {
        return certificate;
    }

    public void setCertificate(Certificate certificate) {
        this.certificate = certificate;
    }

    @Override
    public String toString() {
        return "certificate field [id=" + getId() + ", name=" + getName()+ ", value=" + getValue()+"]";
    }
}
EN

回答 1

Stack Overflow用户

发布于 2017-06-02 16:48:46

我决定了。问题出在更新hbm2ddl的意义上。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44303462

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档