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: about Table per concrete class, using implicit polymorphism
PostPosted: Sun Aug 27, 2006 6:15 am 
Beginner
Beginner

Joined: Sun Aug 13, 2006 8:48 am
Posts: 23
Hibernate version: 3.2

Name and version of the database you are using:Mysql 5.0.22

classes:

Company.java

Employee.java(has tow subclasses)
|
|--HourlyEmployee.java
|
|
|--SalariedEmployee.java

The relationship between Company.java and Employee.java is one-to-many

I want to mapping them by the strategy of Table per concrete class, using implicit polymorphism

Employee.hbm.xml

Code:
<?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="ergal.HourlyEmployee" table="HOURLY_EMPLOYEES" polymorphism="implicit">
      <id name="id" type="long" column="HOURLY_EMPLOYEE_ID">
         <generator class="native"/>
      </id>
      <property name="name" column="NAME" type="string"/>
      <property name="rate" column="RATE" type="double"/>
      
      
      <many-to-one
         name="company"
         column="COMPANY_ID"
         class="mypack.Company"
         />
            
   </class>
   
   <class name="ergal.SalariedEmployee" table="SALARUED_EMPLOYEES" polymorphism="implicit">
      <id name="id" type="long" column="SALARUED_EMPLOYEE_ID">
         <generator class="native"/>
      </id>
      <property name="name" column="NAME" type="string"/>
      <property name="salary" column="SALARY" type="double"/>
      
      
      <many-to-one
         name="company"
         column="COMPANY_ID"
         class="mypack.Company"
         />
      
      
   </class>
   
   <any name="employee" meta-type="string" id-type="long">
      <meta-value value="HE" class="ergal.HourlyEmployee"/>
      <meta-value value="SE" class="ergal.SalariedEmployee"/>
      <column name="EMPLOYEE_TYPE"/>
      <column name="EMPLOYEE_ID"/>
      
   </any>   

   
</hibernate-mapping>   


when I run hbm2ddl
Exception: org.hibernate.InvalidMappingException: Could not pars
e mapping document from resource ergal/Employee.hbm.xml

how to mapping them by the strategy of Table per concrete class, using implicit polymorphism correctly

THX


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.