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