[
http://opensource.atlassian.com/projects/hibernate/browse/ANN-722?page=co...
]
Hardy Ferentschik commented on ANN-722:
---------------------------------------
Added the test case to the source code and got the same error. Even though a valid case it
seems to me very artificial. Nevertheless, it seems to be sufficient to just switch to
the default inheritance strategy in class B by removing '(strategy =
InheritanceType.JOINED)'. Then the test will pass and the generated schema looks
correct.
Need to track down now why the example won't work for InheritanceType.JOINED.
ANN-694 alive: FK circularity error under certain circumstances
---------------------------------------------------------------
Key: ANN-722
URL:
http://opensource.atlassian.com/projects/hibernate/browse/ANN-722
Project: Hibernate Annotations
Issue Type: Bug
Components: binder
Affects Versions: 3.3.1.GA
Environment: core 3.2.6, annotations 3.3.1.GA, entitymanager 3.3.2.GA,
mysql 5
Reporter: Sven Woltmann
Priority: Blocker
Fix For: 3.3.2, 3.4.0.CR2
Attachments: CircularityTest2.rar
The bug described in ANN-694 still exists in 3.3.1.GA under the following circumstances
(see below for further description):
------------------------------------------------------------
@Entity
public class A_PK implements Serializable {
public D d;
@ManyToOne
public D getD() {
return d;
}
public void setD(D d) {
this.d = d;
}
}
------------------------------------------------------------
@Entity
public class A implements Serializable {
private A_PK id;
@EmbeddedId
public A_PK getId() {
return id;
}
public void setId(A_PK id) {
this.id = id;
}
}
------------------------------------------------------------
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class B implements Serializable {
@Id
private int id;
}
------------------------------------------------------------
@Entity
public class C extends B implements Serializable {
}
------------------------------------------------------------
public class D_PK implements Serializable {
private C c;
@ManyToOne
public C getC() {
return c;
}
public void setC(C c) {
this.c = c;
}
}
------------------------------------------------------------
@Entity
public class D implements Serializable {
private D_PK id;
@EmbeddedId
public D_PK getId() {
return id;
}
public void setId(D_PK id) {
this.id = id;
}
}
------------------------------------------------------------
The references are as follows - there are no circularity dependencies:
A --> A_PK --> D --> D_PK --> C --> B
------------------------------------------------------------
Hibernate throws the following exception:
org.hibernate.AnnotationException: Foreign key circularity dependency involving the
following tables: D, C, A
at
org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:470)
at
org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:304)
at org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:762)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:93)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:61)
at test.DoTest.initTest(DoTest.java:22)
------------------------------------------------------------
When I do any of the following, *no* exception is thrown:
- class A_PK: reference "C" instead of "D" (removing "C"
from the dependency chain)
- class A: move annotation from getter to field declaration "private A_PK id"
- class A: replace embedded id "A_PK" by reference to "D" (as in
"A_PK")
- class A: rename class to "Z"
- class B: remove "strategy" parameter from "@Inheritance"
annotation
- class C: not extending "B" and defining the primary key in "C"
- class C: rename class to "Z"
- class D: move annotation from getter to field declaration "private D_PK id"
- class D: replace embedded id "D_PK" by reference to "C" (as in
"D_PK")
Attached you'll find a test case.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira