-->
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: 2.1 RC1 foreign key column length
PostPosted: Tue Dec 09, 2003 7:37 am 
Newbie

Joined: Thu Oct 23, 2003 6:39 pm
Posts: 16
Hi there
I'm struggeling to integrate a legacy system with hibernate. All ids are assigned, many composite. Problem is that 2.1 RC1 seems to ignore the length of the id of the referenced column in many-to-many relationships.
Case:
2 persistent classes, Item and AcademicGroup in a bidirectional relationship, both have assigned string ids of length 16. Xdoclet generates the following mapping, which looks ok to me:

Extraxt from class OaseAcademicGroup
Code:
.....
        <id
            name="id"
            column="id"
            type="string"
            length="16"
        >
            <generator class="assigned">
            </generator>
        </id>
.....
      <set
            name="academicGroups"
            table="item_academicgroup"
            lazy="true"
            inverse="false"
            cascade="none"
            sort="unsorted"
            order-by="academicgroup"
        >

              <key
                  column="item"
              />

              <many-to-many
                  class="net.hardersen.sl.oase.model.OaseAcademicGroup"
                  column="academicgroup"
                  outer-join="auto"
              />

        </set>
......

Extract from class OaseItem
Code:
.......
       <id
            name="ean"
            column="ean"
            type="string"
            length="16"
        >
            <generator class="assigned">
            </generator>
        </id>
.......
        <set
            name="items"
            table="item_academicgroup"
            lazy="true"
            inverse="true"
            cascade="none"
            sort="unsorted"
            order-by="item"
        >

              <key
                  column="academicgroup"
              />

              <many-to-many
                  class="net.hardersen.sl.oase.model.OaseItem"
                  column="item"
                  outer-join="auto"
              />

        </set>
......


The SchemaExport generates the base (item and academicgroup) tables fine, but in the item_academicgroup table it ignores the id length of 16, and makes the columns 255 in size. This makes MaxDB (SAP DB) pissed, as referencing columns have to be of the exact same type.

I can think of a few ways to get around this, such as not using SchemaExport, making the lenght of the id columns 255, but none are good. Any ideas?

Thanks a lot! Keep up the good work.
T


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2003 11:30 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Something like
Code:
<key>
  <column="academicgroup" length="16"/>
</key>

should work

Or maybe
Code:
<many-to-many ...>
  <column="academicgroup" length="16"/>
</many-to-many>


I don't which one SchemaExport use.

_________________
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.