-->
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: uuid in many-to-many relationships?
PostPosted: Wed Sep 14, 2005 3:05 pm 
Beginner
Beginner

Joined: Fri Jan 07, 2005 11:07 am
Posts: 30
Hi, I have two classes Person and Subject. There is a many-to-many relationship between them. The interesting thing is that Person uses
uuid-style id, NOT numbers. Here is the hibernate mapping file for Person:

<class name="Person" table="PERSON">

<id name="id" type="string">
<column name="ID" sql-type="CHAR(32)"/>
<generator class="uuid.hex"/>
</id>

<set name="subjects" table="PERSON_SUBJECT" cascade="all-delete-orphan" lazy="true">
<key column="PERSON_ID"/>
<many-to-many class="Subject" column="SUBJECT_ID"/>
</set>

</class>

The following mapping is for Subject:

<class name=Subject"
table="SUBJECT">

<id name="id" type="long" column="ID">
<generator class="native"/>
</id>

<property name="name" type="string">
<column name="NAME" length="150"/>
</property>

</class>



When I use Hibernate to create database tables, I always get the following error message:

[hibernatetool] 10:00:17,125 ERROR SchemaExport:167 - Unsuccessful: alter table PERSON_SUBJECT add constraint FK225EBD9AF2EBA0FC foreign key (PERSON_ID) references PERSON
[hibernatetool] 10:00:17,125 ERROR SchemaExport:168 - Column 'PERSON.ID' is not the same data type as referencing column 'PERSON_SUBJECT.PERSON_ID' in foreign key 'FK225EBD9AF2EBA0FC'.

If I use number as Person's id, then there is no such problem.

Did I do something wrong? or Do I have to have special treatment for UUID-style IDs in associations?

Regards,
Pete


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2005 4:45 pm 
Beginner
Beginner

Joined: Fri Jan 07, 2005 11:07 am
Posts: 30
Some background info:

I use Hibernate 3.0.


Thanks!


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.