I'm getting the error message "Collection of elements must not have mappedBy or association reference an unmapped class" from Hibernate when I try to initialize a session. It seems like the mapping that I'm trying to use should be possible. My hibernate.cfg.xml has mapping entries for all 3 classes listed below in it. Regardless of what the problem is here, the error message certainly seems to be wrong, since there are no unmapped classes involved here.
Hibernate version: 3.1rc1
Hibernate Annotations version: 3.1b6
Mapping documents:
Code:
A.java:
@Entity
@Table(name="A")
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public class A extends SuperA {
private Set<B> _bs = new HashSet<B>();
@OneToMany(mappedBy="a")
public Set<B> getBs() {
return _bs;
}
}
B.java:
@EmbeddableSuperclass
public abstract class B extends SuperB {
private A _a;
@ManyToOne
@JoinColumn(name="AID")
public A getA() {
return _a;
}
}
C.java:
@Entity
@Table(name="C")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE,
discriminatorType=DiscriminatorType.STRING,
discriminatorValue="C"
)
public class C extends B {
...
Full stack trace of any exception that occurs:
Collection of elements must not have mappedBy or association reference an unmapped class: A.bs
org.hibernate.AnnotationException: Collection of elements must not have mappedBy or association reference an unmapped class: A.bs
at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:689)
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:407)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:368)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:35)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1023)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:218)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1138)
at com.adapt.clcm.storage.StorageService.getSessionFactory(StorageService.java:55)
at com.adapt.clcm.storage.StorageService.getSession(StorageService.java:42)
at com.adapt.clcm.model.ModelTest.setUp(ModelTest.java:20)
at com.adapt.clcm.core.test.BaseTestCase.runBare(BaseTestCase.java:40)
Name and version of the database you are using: Hypersonic 1.8.0.1
Debug level Hibernate log excerpt:
18:04:40 DEBUG CollectionSecondPass : Second pass for collection: A.bs
18:04:40 DEBUG CollectionBinder : Binding a collection of element: A.bs