Repeated column chack fails with SingleTable inheritance, biut not with TablePerClass

Description

Not sure about component.

Parent class introduce field, which is also discriminator field.
Hibernate reports error in child class if and only if strategy = InheritanceType.SINGLE_TABLE

org.hibernate.MappingException: Repeated column in mapping for entity: ru.arptek.arpsite.data.discriminator.IntegerSingleChild column: type (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:590)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:612)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:630)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:405)
at org.hibernate.mapping.SingleTableSubclass.validate(SingleTableSubclass.java:43)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1026)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1211)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:631)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:760)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:627)
at ru.arptek.arpsite.data.AbstractHibernateJUnitTest.setUp(AbstractHibernateJUnitTest.java:89)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
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)

Test cas works with strategy = InheritanceType.TABLE_PER_CLASS

Environment

HA last from SVN, HEM last from SVN, MySQL

Activity

Show:
Sergey Vladimirov
August 10, 2006, 10:06 AM

Test case added

Jürgen Moßgraber
July 18, 2007, 9:48 AM

Annotate the discriminator field with

@Column(insertable = false, updatable = false)

which solved the problem for me.

Sergey Vladimirov
July 18, 2007, 11:32 AM

Jürgen,

The problem is:

  • Hibernate didn't report the error if strategy != InheritanceType.SINGLE_TABLE

The repeated problem column is already fixed, but it was very hard to find it - because of this issue.

Emmanuel Bernard
July 18, 2007, 10:41 PM

Only SINGLE_TABLE uses the discriminator column, that's why it's the only one leveraging the mapping error.

Steve Ebersole
March 21, 2011, 7:04 PM

Bulk closing stale resolved issues

Assignee

Unassigned

Reporter

Sergey Vladimirov

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure