-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Can a Discriminator belong to a Composite-id?
PostPosted: Tue Apr 12, 2005 10:09 am 
Newbie

Joined: Tue Apr 12, 2005 9:47 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.