-->
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: Discriminator not working
PostPosted: Sun Sep 24, 2006 7:29 pm 
Regular
Regular

Joined: Fri Mar 04, 2005 1:33 pm
Posts: 65
Location: U.K.
I am using Hibernate 3.1. I have a simple table Employee. I want to use discriminator on a column called Emp_Type_Id. A specific value of this discriminator should create a subclass called Manager. Can you please tell me what did I define wrong in following hbm.xml as it is not creating a subclass pojo?

Thanks in advance
R




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

<hibernate-mapping>
<class name="com.adf.business.Employee" discriminator-value="5" table="EMPLOYEE">
<id name="id" type="java.lang.Long" unsaved-value="null">
<column name="ID" precision="15" scale="0" />
<generator class="sequence">
<param name="sequence">EMPLOYEE_ID</param>
</generator>
</id>


<discriminator type="java.lang.Long" force="false" insert="true">
<column name="EMP_TYPE_ID"/>
</discriminator>

<version name="version" type="java.lang.Long">
<column name="VERSION" precision="10" scale="0" not-null="true" />
</version>

<many-to-one name="empType" class="com.adf.business.EmpType" fetch="select">
<column name="EMP_TYPE_ID" precision="10" scale="0" not-null="true" />
</many-to-one>

<many-to-one name="workObj" class="com.adf.business.WorkObj" fetch="select">
<column name="WORK_OBJECTIVE_ID" precision="15" scale="0" not-null="true" />
</many-to-one>

<property name="joinDate" type="date">
<column name="JOIN_DATE" length="7" not-null="true" />
</property>

<subclass name="Manager" discriminator-value="2">
<property name="joinDate" type="date">
<column name="JOIN_DATE" length="7"/>
</property>
</subclass>

</class>
</hibernate-mapping>


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.