Hi guys,
I came across a problem with a legacy schema mapping.
I have 3 tables, A, B, C, A has a reference to B, B has a reference to C. Both these references are a part of a primary key of a respective table.
So I mapped it like this:
Code:
@Entity
public class A {
@EmbeddedId
private AId id;
}
@Embeddable
public class AId {
private int aId;
@ManyToOne
private B b;
}
@Entity
public class B {
@EmbeddedId
private B id;
}
@Embeddable
public class BId {
private int bId;
@ManyToOne
private C c;
}
@Entity
public class C {
@Id
private int id;
}
The simple test code blows up with an exception:
Code:
Configuration cfg = new Configuration().addAnnotatedClass(A.class).addAnnotatedClass(B.class).addAnnotatedClass(C.class);
cfg.setProperty(AvailableSettings.DIALECT, H2Dialect.class.getName());
cfg.buildSessionFactory();
Quote:
java.lang.StackOverflowError
at org.hibernate.cfg.AbstractPropertyHolder.isInIdClass(AbstractPropertyHolder.java:150)
at org.hibernate.cfg.AbstractPropertyHolder.isInIdClass(AbstractPropertyHolder.java:150)
at org.hibernate.cfg.AbstractPropertyHolder.isInIdClass(AbstractPropertyHolder.java:150)
at org.hibernate.cfg.AbstractPropertyHolder.isInIdClass(AbstractPropertyHolder.java:150)
...
at org.hibernate.cfg.AbstractPropertyHolder.isInIdClass(AbstractPropertyHolder.java:150)
at org.hibernate.cfg.BinderHelper.getPropertyOverriddenByMapperOrMapsId(BinderHelper.java:819)
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:2169)
at org.hibernate.cfg.AnnotationBinder.fillComponent(AnnotationBinder.java:2629)
at org.hibernate.cfg.AnnotationBinder.fillComponent(AnnotationBinder.java:2524)
at org.hibernate.cfg.AnnotationBinder.bindComponent(AnnotationBinder.java:2473)
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:2198)
at org.hibernate.cfg.AnnotationBinder.fillComponent(AnnotationBinder.java:2629)
at org.hibernate.cfg.AnnotationBinder.fillComponent(AnnotationBinder.java:2524)
at org.hibernate.cfg.AnnotationBinder.bindComponent(AnnotationBinder.java:2473)
...
at org.hibernate.cfg.AnnotationBinder.fillComponent(AnnotationBinder.java:2524)
at org.hibernate.cfg.AnnotationBinder.bindComponent(AnnotationBinder.java:2473)
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:2198)
at org.hibernate.cfg.AnnotationBinder.fillComponent(AnnotationBinder.java:2629)
So the question is - is it a legitimate issue, or my mapping is wrong.
Hibernate:
4.3.6.Final