javax.persistence.PersistenceException: org.hibernate.AnnotationException: Foreign key circularity dependency involving the following tables: Droitacces, Benefserv, Acces

Hibernate JIRA | M. Lhotellerie | 9 years ago
  1. 0

    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

    Hibernate JIRA | 9 years ago | M. Lhotellerie
    javax.persistence.PersistenceException: org.hibernate.AnnotationException: Foreign key circularity dependency involving the following tables: Droitacces, Benefserv, Acces
  2. 0

    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

    Hibernate JIRA | 9 years ago | M. Lhotellerie
    javax.persistence.PersistenceException: org.hibernate.AnnotationException: Foreign key circularity dependency involving the following tables: Droitacces, Benefserv, Acces
  3. 0

    Should Hibernate be able to handle overlapping foreign keys?

    Stack Overflow | 6 years ago | Kawu
    javax.persistence.PersistenceException: [PersistenceUnit: geoinfo] Unable to configure EntityManagerFactory
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    OneToOne shared Primary Key, Pure JPA 2.0 Solution works with EclipseLink but fails with with Hibernate Provider

    Stack Overflow | 3 years ago | nirmalsingh
    javax.persistence.PersistenceException: [PersistenceUnit: users] Unable to configure EntityManagerFactory
  6. 0

    Hibernate: AnnotationException: Unknown mappedBy in ... referenced property unknown on reverse (mappedBy), bi-directional @OneToOne associations

    Stack Overflow | 6 years ago | Kawu
    javax.persistence.PersistenceException: [PersistenceUnit: persons] Unable to configure EntityManagerFactory

    4 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.hibernate.AnnotationException

      Foreign key circularity dependency involving the following tables: Droitacces, Benefserv, Acces

      at org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder()
    2. Hibernate
      Configuration.buildMappings
      1. org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:458)
      2. org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:295)
      3. org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
      3 frames
    3. Hibernate EJB
      HibernatePersistence.createEntityManagerFactory
      1. org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1269)
      2. org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:150)
      3. org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:888)
      4. org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:186)
      5. org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:246)
      6. org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:120)
      6 frames
    4. JavaEE 7
      Persistence.createEntityManagerFactory
      1. javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
      2. javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
      2 frames
    5. test
      DoTest.initTest
      1. test.DoTest.initTest(DoTest.java:12)
      1 frame
    6. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      4. java.lang.reflect.Method.invoke(Unknown Source)
      4 frames
    7. JUnit
      TestClassRunner.run
      1. org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
      2. org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
      3. org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
      4. org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
      5. org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
      6. org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
      7. org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
      8. org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
      9. org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
      10. org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
      10 frames
    8. JUnit4 Runner
      JUnit4TestReference.run
      1. org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
      1 frame
    9. JUnit3 Runner
      RemoteTestRunner.main
      1. org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      2. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
      3. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
      4. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
      5. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
      5 frames