hello
i have a question regarding a case where i need to associate an entity type (Bar) inside an embedded type (Foo).
is there any way to do that? it seems that i can't work it out as i constantly get a java.util.ConcurrentModificationException. i use Hibernate 3.5.3 configured with Spring 3 sessionFactory, and it's done quite simply:
Code:
@Entity
public class Bar {
...
}
@Embeddable
public class Foo {
private Bar bar;
@ManyToOne
@JoinColumn("BAR_ID")
public B getB() {
return this.b;
}
public void setB(B b) {
this.b = b;
}
}
now, whenever i try to run this, while loading (before committing any other actions), i keep getting:
Quote:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [META-INF/spring/dao-config.xml]:
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
...
Caused by: java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
at java.util.AbstractList$Itr.remove(AbstractList.java:357)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1222)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:383)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1206)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:717)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1469)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)
... 50 more
if i omit the @ManyToOne annotation everything else is working and the application loads fine.
i don't understand what's wrong with having a @ManyToOne association inside an embedded type? after all, it will be a part of an entity at runtime..
thanks
Yuval