Я новичок в Hibernate.Я потерпел неудачу, когда пытался установить отношения один-ко-многим между двумя классами.
Это выдало ошибку:
Exception in thread "main" java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1912)
at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:796)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:707)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:4035)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3989)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1398)
at org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:1002)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:130)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:92)
at org.hibernate.business.TestBusiness.main(TestBusiness.java:14)
Мои определения:
BusinessCard.java
@OneToMany(targetEntity=BusinessPhone.class, mappedBy="card",
cascade=CascadeType.ALL, fetch=FetchType.EAGER)
public List<BusinessPhone> getPhones() {
return phones;
}
BusinessPhone.java
@ManyToOne
@JoinColumn(name="business_id")
public BusinessCard getCard() {
return card;
}
public void setCard(BusinessCard card) {
this.card = card;
}
Пожалуйста, помогите мне, каков источник ошибки?