Hibernate version: 3
I've been trying to create a mapping to a class which has a composite key. One of the columns of this key is also a discriminator.
Mapping file
Code:
<hibernate-mapping>
<class name="Label" table="Label" discriminator-value="0" abstract="true">
<composite-id name="id" class="SerialNumberId">
<key-property name="typeLabel" type="short">
<column name="typeLabel" />
</key-property>
<key-property name="serialNumber" type="long">
<column name="serialNumber" />
</key-property>
</composite-id>
<discriminator column="typeLabel" type="short"/>
<subclass name="LabelBox"
discriminator-value="2">
</subclass>
</class>
</hibernate-mapping>
When using this mapping, I always end up with this error:org.hibernate.MappingException: Repeated column in mapping for entity: LabelBox column: typeLabel (should be mapped with insert="false" update="false")
Here is the full exception stack trace:
org.hibernate.MappingException: Repeated column in mapping for entity: LabelBox column: typeLabel (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:590)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:629)
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.console.ConsoleConfiguration$2.execute(ConsoleConfiguration.java:282)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:56)
at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:85)
at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:277)
at org.hibernate.eclipse.console.workbench.LazySessionFactoryAdapter.getChildren(LazySessionFactoryAdapter.java:41)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.getChildren(BasicWorkbenchAdapter.java:88)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:94)
at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:207)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
Is there any way to achieve composite-id + discriminator + subclass ? I don't want to create 2 tables in my database...
Thanks