-->
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.  [ 2 posts ] 
Author Message
 Post subject: Table per subclass inheritance mapping
PostPosted: Thu Aug 05, 2004 8:49 pm 
Newbie

Joined: Tue Apr 27, 2004 1:10 am
Posts: 3
I am having trouble trying to understand the 'Table per subclass' inheritance mapping. Chapter 3 of the Hibernate in action book states that "no discriminator is required with this stratergy" yet I can't get the Hibernate Session to load up if my mapping file does not contain the 'discriminator' tag. I get the error message [i]"Hibernate Exception occured building SessionFactory: discriminator mapping required for polymorphic persistence"[/i]

If I do put a default 'discriminator' tag in then try to execute a query I get [i]"Invalid column name 'class'" as the SQL that is generated is looking for a column named 'class'."[/i]

I can get the 'Billing Details-->Credit Card' example in the 'caveatemptor' example application to work but can't see why my mapping file does not work. That example does not have the discriminator tag.

It's probably something obvious but I can't see it.

My 'super' class is not Abstract and I only have one class/table that inherits from it, although I don't see why that would be a problem.

Below is my mapping file, the classes are just simple POJOs.

Thanks
Adrian

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin

http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->

<class
name="milestonegroup.pcontrol.server.domain.system.processflow.ProcessFlow"
table="t570_process_flow"
persister="milestonegroup.util.database.IntegrityAwarePersister"
>
<meta attribute="implements" inherit="false">IProcessFlow</meta>
<meta attribute="extra-import">milestonegroup.pcontrol.processflow.IProcessFlow</meta>
<meta attribute="extra-import">milestonegroup.pcontrol.processflow.IProcessFlowRole</meta>
<meta attribute="extra-import">milestonegroup.pcontrol.processflow.IProcessFlowInstance</meta>
<meta attribute="extra-import">milestonegroup.pcontrol.processflow.IProcessFlowDefinition</meta>
<meta attribute="extra-import">milestonegroup.pcontrol.processflow.IActivity</meta>
<meta attribute="extra-import">milestonegroup.pcontrol.processflow.ITransition</meta>
<meta attribute="implement-equals">true</meta>
<meta attribute="implement-compare">true</meta>

<id
name="id"
type="int"
column="process_flow_id"
access="field"
unsaved-value="-1"
>
<generator class="assigned" />
</id>

<property
name="processFlowDefinitionDescription"
type="java.lang.String"
column="process_flow_definition_description"
length="50"
access="field">
<meta attribute="alt-name">description</meta>
<meta attribute="field-description">description</meta>
</property>
<property
name="defaultOwnerId"
type="milestonegroup.util.database.customtypes.ProcessFlowRoleUserType"
column="default_owner_id"
length="10"
access="field">
<meta attribute="alt-name">defaultOwner</meta>
<meta attribute="property-type">IProcessFlowRole</meta>
</property>
<!--property
name="versionNumber"
type="int"
column="version_number"
length="10"
access="field"
/-->
<property
name="lastUpdatedBy"
type="int"
column="last_updated_by"
length="10"
access="field"
/>
<property
name="lastUpdatedDate"
type="java.lang.String"
column="last_updated_date"
length="17"
access="field"
/>
<property
name="integrityValue"
type="java.lang.String"
column="integrity_value"
length="27"
access="field"
/>

<!-- associations -->
<!-- bi-directional one-to-many association to ProcessFlowDefinitionActivity -->
<bag
name="containedActivities"
lazy="true"
inverse="true"
access="field"
>
<meta attribute="singular-name">containedActivity</meta>
<meta attribute="singular-type">IActivity</meta>
<key>
<column name="process_flow_id" />
</key>
<one-to-many
class="milestonegroup.pcontrol.server.domain.system.processflow.ProcessFlowActivity"
/>
</bag>
<!-- bi-directional one-to-many association to ProcessFlowDefinitionTransition -->
<bag
name="containedTransitions"
lazy="true"
inverse="true"
access="field"
>
<meta attribute="singular-name">containedTransition</meta>
<meta attribute="singular-type">ITransition</meta>
<key>
<column name="process_flow_id" />
</key>
<one-to-many
class="milestonegroup.pcontrol.server.domain.system.processflow.ProcessFlowTransition"
/>
</bag>
<!-- uni-directional many-to-one association to ProcessFlowDefinition -->
<many-to-one
name="mainProcessFlow"
class="milestonegroup.pcontrol.server.domain.system.processflow.ProcessFlowDefinition"
access="field">
<meta attribute="property-type">IProcessFlowDefinition</meta>
<column name="main_process_flow_id" />
</many-to-one>
<!-- bi-directional one-to-many association to ProcessFlowInstance -->
<bag
name="instances"
lazy="true"
inverse="true"
access="field"
>
<meta attribute="singular-type">IProcessFlowInstance</meta>
<meta attribute="singular-name">instance</meta>
<meta attribute="scope-set">protected</meta>

<key>
<column name="process_flow_definition_id" />
</key>
<one-to-many
class="milestonegroup.pcontrol.server.domain.system.processflow.ProcessFlowInstance"
/>
</bag>
<!-- bi-directional one-to-many association to ProcessFlowDefinitionAttribute -->
<bag
name="processFlowDefinitionAttributes"
lazy="true"
inverse="true"
access="field"
>
<key>
<column name="process_flow_defintion_id" />
</key>
<one-to-many
class="milestonegroup.pcontrol.server.domain.system.processflow.ProcessFlowAttribute"
/>
</bag>
<!-- uni-directional one-to-one association to ProcessFlowDefinitionActivity (although it says many-to-one, unique="true" forces one-to-one)-->
<many-to-one
name="startActivity"
class="milestonegroup.pcontrol.server.domain.system.processflow.ProcessFlowActivity"
unique="true"
not-null="true"
access="field"
>
<meta attribute="property-type">IActivity</meta>
<column name="start_activity" />
</many-to-one>


<joined-subclass name="milestonegroup.pcontrol.server.domain.system.processflow.ProcessFlowDefinition"
table="t581_process_flow_definition"
persister="milestonegroup.util.database.IntegrityAwarePersister"
>
<meta attribute="implements">IProcessFlowDefinition</meta>
<meta attribute="extra-import">milestonegroup.pcontrol.processflow.IAttributeDefinition</meta>
<meta attribute="extra-import">milestonegroup.pcontrol.processflow.IProcessFlow</meta>
<meta attribute="extra-import">milestonegroup.pcontrol.processflow.IProcessFlowStatus</meta>
<meta attribute="extra-import">milestonegroup.pcontrol.processflow.IProcessFlowDefinition</meta>
<meta attribute="extra-import">milestonegroup.pcontrol.processflow.IActivity</meta>
<meta attribute="extra-import">milestonegroup.pcontrol.processflow.IProcessFlowRole</meta>
<key column="process_flow_definition_id"/>

<property
name="status"
type="int"
column="status"
not-null="true"
length="10"
access="field">
<meta attribute="property-type">IProcessFlowStatus</meta>
</property>
<property
name="version"
type="int"
column="version_number"
not-null="true"
length="10"
access="field"
/>
<!--<property
name="lastUpdatedBy"
type="int"
column="last_updated_by"
not-null="true"
length="10"
access="field"
insert="false"
update="false"
/>
<property
name="lastUpdatedDate"
type="java.lang.String"
column="last_updated_date"
not-null="true"
length="17"
access="field"
insert="false"
update="false"
/>
<property
name="integrityValue"
type="java.lang.String"
column="integrity_value"
not-null="true"
length="50"
access="field"
insert="false"
update="false"
/>-->

<!-- associations -->
<!-- uni-directional many-to-one association to ProcessFlow -->
<many-to-one
name="onCompletionProcessFlow"
class="milestonegroup.pcontrol.server.domain.system.processflow.ProcessFlow"
not-null="true"
access="field"
>
<meta attribute="property-type">IProcessFlow</meta>
<column name="on_completion_process_flow_id" />
</many-to-one>
<!-- uni-directional many-to-one association to ProcessFlow -->
<many-to-one
name="onCancelProcessFlow"
class="milestonegroup.pcontrol.server.domain.system.processflow.ProcessFlow"
not-null="true"
access="field"
>
<meta attribute="property-type">IProcessFlow</meta>
<column name="on_cancel_process_flow_id" />
</many-to-one>
<!-- uni-directional one-to-many association to ProcessFlowAttribute -->
<bag
name="attributeDefinitions"
lazy="true"
>
<meta attribute="scope-set">protected</meta>
<meta attribute="singular-name">attributeDefinition</meta>
<meta attribute="singular-type">IAttributeDefinition</meta>
<key>
<column name="process_flow_defintion_id"/>
</key>
<one-to-many
class="milestonegroup.pcontrol.server.domain.system.processflow.ProcessFlowAttribute"
/>
</bag>

</joined-subclass>

</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 05, 2004 9:02 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You're mistaken, you have some other mapping file which has a <subclass> mapping.


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

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.