[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-4832) Secondary tables do not work with TABLE_PER_CLASS inheritance strategies
Emmanuel Bernard (JIRA)
noreply at atlassian.com
Thu Jul 8 05:15:13 EDT 2010
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4832?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Emmanuel Bernard updated HHH-4832:
----------------------------------
Summary: Secondary tables do not work with TABLE_PER_CLASS inheritance strategies (was: Secondary tables do not work in JOINED or TABLE_PER_CLASS inheritance strategies)
Change title, JOINED is now supported as per HHH-4240
> Secondary tables do not work with TABLE_PER_CLASS inheritance strategies
> ------------------------------------------------------------------------
>
> Key: HHH-4832
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4832
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.3.2
> Environment: Hibernate 3.3.2, Postgres 8.4.2
> Reporter: Simon Godden
> Attachments: hibernatetest2.tgz
>
>
> I have a class hierarchy as follows:
> {noformat}
> Abstract RootClass (Mapped Superclass)
> |
> \ /
> Abstract IntermediateClass (Entity)
> | |
> \ / \ /
> LeafClass (Entity) LeafClass2 (Entity)
> {noformat}
> The following table shows which attributes are on each class:
> ||Class||Attribute||Table||
> |RootClass|field1|rootclass|
> |IntermediateClass|field2|intermediateclass|
> |LeafClass|field3|leafclass|
> |LeafClass|field4|leafclass2|
> |AnotherLeafClass|field5|anotherleafclass|
> |AnotherLeafClass|field6|anotherleafclass2|
> Using {{InheritanceType.SINGLE_TABLE}}, it works.
> Using {{InheritanceType.JOINED}} or {{InheritanceType.TABLE_PER_CLASS}} at the {{IntermediateClass}} level causes different errors:
> Using {{InheritanceType.JOINED}} causes an incorrect insert statement which thinks that {{field4}} is on table {{leafclass}} rather than {{leafclass2}}:
> {noformat}
> Hibernate:
> insert
> into
> LeafClass
> (field1, field2, field3, field4, id)
> values
> (?, ?, ?, ?, ?)
> Exception in thread "main" [22/01/10 03:17:53:053 GMT] WARN util.JDBCExceptionReporter: SQL Error: 0, SQLState: null
> [22/01/10 03:17:53:053 GMT] ERROR util.JDBCExceptionReporter: Batch entry 0 insert into LeafClass (field1, field2, field3, field4, id) values (foo1, foo2, foo3, foo4, 1) was aborted. Call getNextException to see the cause.
> [22/01/10 03:17:53:053 GMT] WARN util.JDBCExceptionReporter: SQL Error: 0, SQLState: 42703
> [22/01/10 03:17:53:053 GMT] ERROR util.JDBCExceptionReporter: ERROR: column "field4" of relation "leafclass" does not exist
> {noformat}
> Using {{InheritanceType.TABLE_PER_CLASS}} causes the following error as the session factory is built:
> {noformat}
> [22/01/10 03:06:05:005 GMT] INFO cfg.SettingsFactory: Echoing all SQL to stdout
> [22/01/10 03:06:05:005 GMT] INFO cfg.SettingsFactory: Statistics: disabled
> [22/01/10 03:06:05:005 GMT] INFO cfg.SettingsFactory: Deleted entity synthetic identifier rollback: disabled
> [22/01/10 03:06:05:005 GMT] INFO cfg.SettingsFactory: Default entity-mode: pojo
> [22/01/10 03:06:05:005 GMT] INFO cfg.SettingsFactory: Named query checking : enabled
> [22/01/10 03:06:05:005 GMT] INFO impl.SessionFactoryImpl: building session factory
> [22/01/10 03:06:06:006 GMT] ERROR hibernate.AssertionFailure: an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
> org.hibernate.AssertionFailure: Table leafclass2 not found
> at org.hibernate.persister.entity.JoinedSubclassEntityPersister.getTableId(JoinedSubclassEntityPersister.java:480)
> at org.hibernate.persister.entity.JoinedSubclassEntityPersister.<init>(JoinedSubclassEntityPersister.java:259)
> at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:87)
> at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:267)
> at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
> at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
> at tests.inheritdomain.SessionManager.initialiseSessionFactory(SessionManager.java:23)
> at tests.inheritdomain.SessionManager.openSession(SessionManager.java:14)
> at tests.inheritdomain.TestSecondaryTablesInInheritance.test(TestSecondaryTablesInInheritance.java:20)
> at tests.inheritdomain.TestSecondaryTablesInInheritance.main(TestSecondaryTablesInInheritance.java:44){noformat}
> A minimal test case is attached as an maven and eclipse project. mvn test will show the error. I have not created a test case for each inheritance type - you will have to change it in the intermediate domain class to see the other error.
--
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