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: Use the special property 'class' with union-subclass mapping
PostPosted: Mon Aug 17, 2009 12:01 pm 
Newbie

Joined: Wed Jul 27, 2005 11:02 am
Posts: 3
I my application, I use a table per concrete class hierarchy strategy.
I didn't introduce a discriminant column into my tables as this information is useless for Hibernate with this mapping.

My mapping file looks like:

<hibernate-mapping>

<!--
Mapping for Super class
-->
<class name="SuperClass" abstract="true">
<id name="objectId" type="string" unsaved-value="null">
<column name="OBJECT_ID" sql-type="char(32)" not-null="true"/>
<generator class="uuid.hex"/>
</id>

<version name="versionNumber" column="VERSION_NUMBER"/>
......

<union-subclass name="SubClassA" table="SUBCLASS_A">
<property name="businessId" column="BUSINESS_ID" not-null="true"/>
.......
</union-subclass>

<union-subclass name="SubClassB" table="SUBCLASS_B">
<property name="businessId" column="BUSINESS_ID" not-null="true"/>
.......
</union-subclass>
.....
</class>
</hibernate-mapping>

Then, I want to build a polymorphic HQL request using the 'class' property, an error is raised.
The request is "select obj.class from SuperClass obj"

So, the question is: Must I add a discriminator column if I want to use the class property even is this information is useless for Hibernate ?

Thanks a lot in advance for any help.
(Note I use hibernate version 3.1.3)


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.