Hibernate version: 2
Hi,
I am trying to create a mapping where my class hierarchy will be persisted in a single table. Each subclass could have an instance with the same 'logical' primary key value. Therefore, I need to add the discriminator to the real primary key definition to enforce unicity.
I have tried the following mapping :
<class
name="MyClass"
table="MY_TABLE
dynamic-update="false"
dynamic-insert="false"
discriminator-value="GNRC"
>
<composite-id
name="MyClassKey"
class="MyClassKey"
>
<key-property
name="name"
type="string"
column="NAME"
length="100"
/>
<key-property
name="type"
type="string"
column="TYPE"
length="4"
/>
</composite-id>
<discriminator
column="TYPE"
type="string"
/>
....
Doing that, I am getting the following exception :
net.sf.hibernate.MappingException: Repeated column in mapping for class MyClass should be mapped with insert="false" update="false": TYPE
Any idea on how to achieve that kind of mapping? Is it possible or should I have a table per subclass?
Thanks,
Alain
|