Note that there are some explanatory texts on larger screens.

plurals
  1. PObidirectional hibernate relationship
    text
    copied!<p>I have a web application using hibernate and the following entities. What am I doing wrong?</p> <pre><code>... @Entity public class Registration implements BaseEntity { ... @OneToMany(cascade = {CascadeType.PERSIST}, mappedBy = "registration", fetch = FetchType.EAGER) private List&lt;OrderedProduct&gt; orderedProducts = new ArrayList&lt;OrderedProduct&gt;(); ... public List&lt;OrderedProduct&gt; getOrderedProducts() { return orderedProducts; } public void setOrderedProducts(List&lt;OrderedProduct&gt; orderedProducts) { this.orderedProducts = orderedProducts; } ... </code></pre> <hr> <pre><code>... @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; } ... </code></pre> <hr> <p>When I use this, I get the following Tomcat Error:</p> <pre><code>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 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload