hi, i have a webapplication, using hibernate and the following entities. What do I wrong:
...
@Entity
public class Registration implements BaseEntity {
...
@OneToMany(cascade = {CascadeType.PERSIST}, mappedBy = "registration", fetch = FetchType.EAGER)
private List<OrderedProduct> orderedProducts = new ArrayList<OrderedProduct>();
...
public List<OrderedProduct> getOrderedProducts() {
return orderedProducts;
}
public void setOrderedProducts(List<OrderedProduct> orderedProducts) {
this.orderedProducts = orderedProducts;
}
...
...
@Entity
public class OrderedProduct implements BaseEntity {
...
@ManyToOne
@JoinColumn(name = "registration_id",nullable = true)
private Registration registration;
...
public Registration getRegistration() {
return registration;
}
public void setRegistration(Registration registration) {
this.registration = registration;
}
...
when I use this, I get following Tomcat Error:
Caused by: org.hibernate.AnnotationException: Illegal use of mappedBy on both sides of the relationship: at.irian.conference.domain.Registration.orderedProducts at org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:193) at org.hibernate.cfg.annotations.CollectionBinder.bindCollectionSecondPass(CollectionBinder.java:1325) at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1164) at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:602) at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:543) at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:66) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1163) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:329) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1148) at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1226) at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:173) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:854) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:425) at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:131) at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:221) at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:251) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1288) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1257) ... 86 more