I have class Document
, which contains field Ad ad
with @OneToOne
annotation. Class ResultDocument extends Document, JOINED
inheritance strategy is applied. When I start my app, I get error: org.hibernate.MappingException: property [ad] not found on entity [ua.translate.model.ad.ResultDocument]
Please, explain me cause of this error.
class Document:
@Entity
@Table(name = "INIT_DOCUMENT_TEST")
@Inheritance(strategy = InheritanceType.JOINED)
public class Document {
@Id
@SequenceGenerator(name = "standart",initialValue = 1)
@GeneratedValue(generator = "standart",strategy =GenerationType.SEQUENCE)
@Column(name = "DOCUMENT_ID")
private long id;
@Lob
@Column(name = "DOCUMENT_FILE",nullable = false)
private byte[] file;
@Column(name = "DOCUMENT_FILE_NAME",nullable = false)
private String fileName;
@Column(name = "DOCUMENT_CONTENT_TYPE",nullable = false)
private String contentType;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "DOCUMENT_AD_ID")
private Ad ad;
.....
}
class ResultDocument:
@Entity
@Table(name = "RESULT_DOCUMENT_TEST")
@PrimaryKeyJoinColumn(name= "result_document_id")
public class ResultDocument extends Document{
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "TRANSLATOR",nullable = false)
private Translator downloader;
.....
}
我认为您不应该从Document扩展,因为如果您使用的是hibernate或JPA,该技术将使用该关系而不执行继承。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.