[hibernate-issues] [Hibernate-JIRA] Updated: (ANN-722) ANN-694 alive: FK circularity error under certain circumstances

Emmanuel Bernard (JIRA) noreply at atlassian.com
Sat May 31 14:30:34 EDT 2008


     [ http://opensource.atlassian.com/projects/hibernate/browse/ANN-722?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Bernard updated ANN-722:
---------------------------------

    Fix Version/s: 3.4.0.CR2

> 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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list