-->
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: SchemaExport Problem with Foreign Key Lengths in Lists?
PostPosted: Wed Jul 21, 2004 11:48 am 
Newbie

Joined: Tue May 04, 2004 6:31 pm
Posts: 11
Hello All,

It appears that Hibernate is ignoring the key column length that I specify in my XXX.hbm.xml files for one-to-many lists and joined-subclasses.

Here is a snippet
Code:
User.hbm.xml

...
   <id name="user_id" type="string" length="27">
      <generator class="assigned"/>
   </id>

...

   <list name="learningLogEntries" table="FT_LEARNING_LOG_ENTRY" cascade="all">
      <key>
         <column name="user_id" length="27" />
      </key>
      <index column="entry_index"/>
      <one-to-many class="edu.byu.cid.familytogether.bean.LearningLogEntry"/>
   </list>
....


You can see that I am specifying the user_id length to be 27, and then I try to specify the length of the key column for my learning log entries to be 27 also.



But MS SQL Server still complains:
Code:
alter table FT_LEARNING_LOG_ENTRY add constraint FK7105FEA7F73AEE0F foreign key (user_id) references FT_USER
[main] ERROR net.sf.hibernate.tool.hbm2ddl.SchemaExport - Unsuccessful: alter table FT_LEARNING_LOG_ENTRY add constraint FK7105FEA7F73AEE0F foreign key (user_id) references FT_USER
[main] ERROR net.sf.hibernate.tool.hbm2ddl.SchemaExport - [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Column 'FT_USER.user_id' is not the same length as referencing column 'FT_LEARNING_LOG_ENTRY.user_id' in foreign key 'FK7105FEA7F73AEE0F'.


This is because the user_id defaults to 255 in the FT_LEARNING_LOG_ENTRY table even though I am trying to set it to 27 in the xxx.hbm.xml file in the list.


Here is the ddl output of schemaExport for the creation of one of the tables:
Code:
create table FT_LEARNING_LOG_ENTRY (
   entry_id VARCHAR(27) not null,
   title VARCHAR(255) null,
   date DATETIME null,
   publicEntry TINYINT null,
   entry TEXT null,
   user_id VARCHAR(255) null,
   entry_index INT null,
   primary key (entry_id)
)


You can see that user_id is 255, even though I tried to specify it to be 27.

Am I doing something wrong or is there a problem with SchemaExport?

Thanks!
--
Nathan

PS I found this article, but I already tried separating out the tags for they key column in my list (before I had tried...
Code:
<key name="user_id" length="27"/>

But the dtd wouldn't allow it.)

PPS I just removed the length="27" on my PRIMARY KEY user_id and then everything defaults to 255 (which I suppose is okay)... but is there anyway make it be any other length?

Hibernate 2.1


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 21, 2004 3:22 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This should be fixed in CVS.


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.