[
http://opensource.atlassian.com/projects/hibernate/browse/ANN-694?page=co...
]
Diego Miranda commented on ANN-694:
-----------------------------------
I had the same problem. To solve it, I had to rename the tables of the DB in the order by
hierarchy of the classes. For example:
Class "C" has a class "B" that has a class "A". The name of
the tables for the classes are, respectively, "tb_c", "tb_b" and
"tb_a".
I had to rename the tables to "tb_xc", "tb_yb" and "tb_za",
respectively, in order to let the table names in an hierarchy order.
It seems an hibernate bug.
I expect that comment help someone.
Bye.
Circularity check error caused by naming conflicts of tables or/and
keys
------------------------------------------------------------------------
Key: ANN-694
URL:
http://opensource.atlassian.com/projects/hibernate/browse/ANN-694
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.3.1.beta1
Environment: core 3.2, annotations 3.3.0.GA, entitymanager 3.3.1.GA
AS400/DB2
Reporter: M. Lhotellerie
Attachments: CircularityTest.zip
As discussed here
http://forum.hibernate.org/viewtopic.php?t=983543, a circularity check
error probably caused by naming conflicts (Tables or/and keys).
These examples work for tables "Acces", "Droitacces" or
"Benefserv"
- rename forgein key "idpkdracc" to something which doesn't begin by
"idpk"
- rename primary key "idpk" to something different of "i",
"id", "idp" and "idpk"
Also you can rename "Droitacces" to "B", but renaming others
class/tables don't seem don't work
@Entity
public class Acces {
@Id
private BigInteger idpk;
@ManyToOne
private Droitacces idpkdracc;
}
//------------------------------------------------------------------
@Entity
public class Droitacces {
@Id
private BigInteger idpk;
@ManyToOne
private Benefserv idpkbenef;
}
//------------------------------------------------------------------
@Entity
public class Benefserv {
@Id
private BigInteger idpk;
@ManyToOne
private Service idpkser;
}
//------------------------------------------------------------------
@Entity
public class Service {
@Id
private BigInteger idpk;
}
//------------------------------------------------------------------
javax.persistence.PersistenceException: org.hibernate.AnnotationException: Foreign key
circularity dependency involving the following tables: Droitacces, Benefserv, Acces
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:258)
at
org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:120)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
at test.DoTest.initTest(DoTest.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
at
org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
at
org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
at
org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.hibernate.AnnotationException: Foreign key circularity dependency
involving the following tables: Droitacces, Benefserv, Acces
at
org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:458)
at
org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:295)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1269)
at
org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:150)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:888)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:186)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:246)
... 24 more
--
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