简体   繁体   English

由以下原因引起:org.hibernate.AnnotationException:XX上的@OneToOne或@ManyToOne引用了未知实体:YY

[英]Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on XX references an unknown entity: YY

Here my target entity which is User.class is present in a separate jar file. 在这里,我的目标实体User.class存在于单独的jar文件中。

package com.aa.model;
    import javax.persistence.Entity;
    import javax.persistence.JoinColumn;
    import javax.persistence.ManyToOne;
    import javax.persistence.OneToOne;

@Entity
@Table(name = "ABC")
public class Abc implements Serializable{
---    
@OneToOne(targetEntity=com.bb.model.User.class)
    @JoinColumn(name  = "CREATED_BY")
    private User createdBy;
}
---
}

The target class: 目标类别:

package com.bb.model;
    import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.Table;

@Entity
@Table(name="USER")
public class User implements Serializable {
---
}

I am getting the following error: 我收到以下错误:

Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.aa.model.Abc.createdBy references an unknown entity: com.bb.model.User
    at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:109)
    at org.hibernate.cfg.Configuration.processEndOfQueue(Configuration.java:1598)

In the class Abc, you wrote 在Abc课上,您写道

@OneToOne(targetEntity=com.bb.User.class)

instead of 代替

@OneToOne(targetEntity=com.bb.model.User.class)

You forgot also the import of com.bb.model package 您还忘记了com.bb.model包的导入

import com.bb.model.User;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 org.hibernate.AnnotationException: @OneToOne 或 @ManyToOne<entity> 引用一个未知实体 - org.hibernate.AnnotationException: @OneToOne or @ManyToOne on <entity> references an unknown entity 引起:org.hibernate.AnnotationException: @OneToOne 或 @ManyToOne on - Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on Java Hibernate org.hibernate.AnnotationException:@OneToOne或@ManyToOne <class> 引用未知实体: <class> - Java Hibernate org.hibernate.AnnotationException: @OneToOne or @ManyToOne on <class> references an unknown entity: <class> org.hibernate.AnnotationException:entities.Ques#tion.examId 上的 @OneToOne 或 @ManyToOne 引用了一个未知实体:long - org.hibernate.AnnotationException: @OneToOne or @ManyToOne on entities.Ques#tion.examId references an unknown entity: long 不断获取 org.hibernate.AnnotationException: @OneToOne 或 @ManyToOne 引用未知实体:错误 - Constantly getting org.hibernate.AnnotationException: @OneToOne or @ManyToOne references an unknown entity: error org.hibernate.AnnotationException: @OneToOne 或 @ManyToOne - org.hibernate.AnnotationException: @OneToOne or @ManyToOne org.hibernate.AnnotationException:@OneToOne on com.abc.dto.Test.name 引用了一个未知实体:com.abc.type.TestName - org.hibernate.AnnotationException:@OneToOne on com.abc.dto.Test.name references an unknown entity: com.abc.type.TestName 线程“ main” org.hibernate.AnnotationException中的异常:@OneToOne或@ManyToOne - Exception in thread “main” org.hibernate.AnnotationException: @OneToOne or @ManyToOne 线程“ main” org.hibernate.AnnotationException中的异常:@OneToOne或@ManyToOne - Exception in thread “main” org.hibernate.AnnotationException: @OneToOne or @ManyToOne on 引起:org.hibernate.AnnotationException:mappedBy 引用了一个未知的目标实体属性 - Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM