SecondaryTable is not taking into account the schema while mapping the entity
Description
Attachments
1
Activity
Show:
Former user May 11, 2018 at 12:24 AM
Fixed in 5.1 and 5.2 branches as well.
sandeep kamath April 5, 2018 at 6:13 AM
Sorry, i didn't realize i assigned it to myself.
Assigning it back to you.
Steve Ebersole March 28, 2018 at 1:56 PM
You assigned it to yourself, so I assume you are doing that...
sandeep kamath March 28, 2018 at 9:59 AM
Request you to backport this to 5.1
Can you also let me know when will this fix be published in 5.1.
Steve Ebersole March 27, 2018 at 7:53 PM
If it gets backported to 5.1 it should probably get backported to 5.2 as well, sure
Fixed
Created March 22, 2018 at 10:35 AM
Updated May 11, 2018 at 8:29 PM
Resolved May 11, 2018 at 12:24 AM
Issue with @SecondaryTable
While upgrading hibernate, i came across issue where we have 2 schema and same table name in both the schema. i have an entity which maps table from both the schemas.
I am getting below error message.
org.hibernate.testing.junit4.CallbackException: org.hibernate.testing.junit4.BaseCoreFunctionalTestCase#buildSessionFactory
at org.hibernate.testing.junit4.TestClassMetadata.performCallbackInvocation(TestClassMetadata.java:203)
at org.hibernate.testing.junit4.TestClassMetadata.invokeCallback(TestClassMetadata.java:187)
at org.hibernate.testing.junit4.TestClassMetadata.performCallbacks(TestClassMetadata.java:181)
at org.hibernate.testing.junit4.TestClassMetadata.performBeforeClassCallbacks(TestClassMetadata.java:172)
at org.hibernate.testing.junit4.BeforeClassCallbackHandler.evaluate(BeforeClassCallbackHandler.java:25)
at org.hibernate.testing.junit4.AfterClassCallbackHandler.evaluate(AfterClassCallbackHandler.java:25)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Caused by: org.hibernate.boot.spi.InFlightMetadataCollector$DuplicateSecondaryTableException: Table with that name [Cluster] already associated with entity
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl$EntityTableXrefImpl.addSecondaryTable(InFlightMetadataCollectorImpl.java:1371)
at org.hibernate.cfg.annotations.EntityBinder.addJoin(EntityBinder.java:980)
at org.hibernate.cfg.annotations.EntityBinder.firstLevelSecondaryTablesBinding(EntityBinder.java:870)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:639)
at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.processEntityHierarchies(AnnotationMetadataSourceProcessorImpl.java:245)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.processEntityHierarchies(MetadataBuildingProcess.java:222)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:265)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83)
at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418)
at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:692)
at org.hibernate.testing.junit4.BaseCoreFunctionalTestCase.buildSessionFactory(BaseCoreFunctionalTestCase.java:112)
at org.hibernate.testing.junit4.BaseCoreFunctionalTestCase.buildSessionFactory(BaseCoreFunctionalTestCase.java:97)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.hibernate.testing.junit4.TestClassMetadata.performCallbackInvocation(TestClassMetadata.java:200)
... 12 more
I discussed this issue in hibernate forum. As per the suggestion i used the template to test the issue in hibernate 4 and hibernate 5. It is working in hibernate 4 but not in hibernate 5.
Please find attached archive extract project test-case-template-hibernate-orm5 and have a look at ORMUnitTestCase.
https://discourse.hibernate.org/t/duplicatesecondarytableexception-table-with-that-name-cluster-already-associated-with-entity/364