-->
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: Char-Type Composite-Key load question
PostPosted: Mon Mar 29, 2004 1:31 am 
Newbie

Joined: Fri Oct 24, 2003 11:53 am
Posts: 2
Location: China
Hibernate can not load correctly child-set at one-to-many mapping type when using hibernate 2.1.2; But when i change into hibernate 2.0.3, hibernate work correctly.

Hibernate Vesion : 2.1.2

mapping documents
Parent mapping file

Code:
<?xml version="1.0" encoding="gb2312"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.tzsoft.test.hibernate.entity.TblGroup" table="TBL_Group">
<id name="groupId" column="Group_Id" type="string" length="50">
   <generator class="uuid.hex"/>
</id>

<property name="groupName" column="Group_Name" type="string" length="100" not-null="true"/>

<set name="personSet" lazy="true" inverse="true" cascade="none">
    <key column="Group_Id"/>
    <one-to-many class="com.tzsoft.test.hibernate.entity.TblPerson"/>
</set>

</class>
</hibernate-mapping>


child mapping file
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.tzsoft.test.hibernate.entity.TblPerson" table="TBL_Person">

<composite-id unsaved-value="any">
   <key-property name="personId" column="Person_Id" type="string" />
   <key-many-to-one name="group" class="com.tzsoft.test.hibernate.entity.TblGroup">
      <column name="Group_Id"/>
   </key-many-to-one>
</composite-id>

<property name="personFirst" column="Person_First" type="string" length="32" not-null="true"/>
<property name="personBirthday" column="Person_Birthday" type="timestamp"/>
<property name="personSalary" column="Person_Salary" type="float"/>
<property name="personLast" column="Person_Last" type="string" length="32"/>
<property name="personInitial" column="Person_Initial" type="string" length="10"/>

</class>
</hibernate-mapping>





load java code
Code:
      TblGroup group = (TblGroup)s.load(TblGroup.class, groupId);
      Set persons = group.getPersonSet();
      Iterator iter = persons.iterator();
      while(iter.hasNext()){
         TblPerson person = (TblPerson)iter.next();
         System.out.println(person);
      }


database: sql server 2000

sql script

Code:
CREATE TABLE [dbo].[TBL_Group] (
   [Group_Id] [char] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
   [Group_Name] [char] (100) COLLATE Chinese_PRC_CI_AS NOT NULL
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[TBL_Person] (
   [Person_Id] [char] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
   [Group_Id] [char] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
   [Person_First] [varchar] (32) COLLATE Chinese_PRC_CI_AS NULL ,
   [Person_Birthday] [datetime] NULL ,
   [Person_Salary] [float] NULL ,
   [Person_Last] [varchar] (32) COLLATE Chinese_PRC_CI_AS NULL ,
   [Person_Initial] [varchar] (10) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO


Thanks .

_________________
己所不欲,勿施于人


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 29, 2004 7:28 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Probably some equals/hashCode implementation broken

_________________
Emmanuel


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.