请告诉我为什么我错误地链接了这些表。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)
@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()+"]";
}
}发布于 2017-06-02 16:48:46
我决定了。问题出在更新hbm2ddl的意义上。
https://stackoverflow.com/questions/44303462
复制相似问题