-->
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: One Class Two Tables Mapping
PostPosted: Sat Jul 11, 2009 11:21 am 
Newbie

Joined: Sat Jul 11, 2009 11:07 am
Posts: 1
I have a class which maps to two tables. I utilized the reference to configure but the configuration does not match with my class. Would you help me the correct configuration, please?

EmployeeDetail.java
Code:
public class EmployeeDetail implements Serializable {
   private static final long serialVersionUID = 1L;   
   private String staffId;
   private String displayName;
   private String deptId;
   private String deptName;
... getter and setter...


EmployeeDetail.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="com.stanley1610.bus.EmployeeDetail" table="Employee"
            entity-name="EmployeeDetail_Employee" lazy="false">
        <id name="staffId" column="staffId">
            <generator class="native"/>
        </id>
        <property name="displayName">
            <column name="displayName"/>
        </property>
        <many-to-one name="deptId"
            entity-name="EmployeeDetail_Department"
            column="deptId"
            not-null="false" />
    </class>
    <class name="com.stanley1610.bus.EmployeeDetail" table="Department"
            entity-name="EmployeeDetail_Department" lazy="false">
        <id name="deptId" column="deptId">
            <generator class="native"/>
        </id>
        <property name="deptName">
            <column name="name"/>
        </property>
    </class>
</hibernate-mapping>


Tables:
Employee {staffId*, displayName, deptId}
Department {deptId*, name}

Error:
2009-07-11 22:56:17,021 ERROR [org.hibernate.property.BasicPropertyAccessor] - IllegalArgumentException in class: com.stanley1610.bus.EmployeeDetail, setter method of property: deptId
2009-07-11 22:56:17,021 ERROR [org.hibernate.property.BasicPropertyAccessor] - expected type: java.lang.String, actual value: com.stanley1610.bus.EmployeeDetail

Please help~


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.