-->
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.  [ 1 post ] 
Author Message
 Post subject: Wrong FKs in DDL with M-M and LightWeight Pattern - Bug?
PostPosted: Fri Apr 09, 2004 11:36 am 
Regular
Regular

Joined: Fri Sep 12, 2003 12:40 pm
Posts: 65
I have two classes where I'm using the lightweight pattern BulletinBoardEntry and BulletinBoardEntryInfo. These are both associated with User in a many to many relationship.

If I include the relationship in both classes and try to generate DDL, I get:

Code:
     [java] alter table bbd_ent_vwd add constraint FK9C0ED3542E530D6A8B172BD5 foreign key (bbd_ent_id) references bbd_cnt;
     [java] CA 2004-04-09 11:06:59,670 main               ERROR net.sf.hibernate.tool.hbm2ddl.SchemaExport  - Unsuccessful: alter table bbd_ent_vwd add constraint FK9C0ED3542E530D6A8B172BD5 foreign key (bbd_ent_id) references bbd_cnt
     [java] CA 2004-04-09 11:06:59,680 main               ERROR net.sf.hibernate.tool.hbm2ddl.SchemaExport  - [IBM][CLI Driver][DB2/NT] SQL0107N  The name "FK9C0ED3542E530D6A8B172BD5" is too long.  The maximum length is "18".  SQLSTATE=42622
     [java] alter table bbd_ent_vwd add constraint FK9C0ED354CE30D3A6 foreign key (usr_id) references users;
     [java] alter table bbd_ent_vwd add constraint FK9C0ED3542E530D6A foreign key (bbd_ent_id) references bbd_cnt;


The foreign key it's trying to generate is already created below.

Is this a bug in the HBM2DDL or a problem with my setup?

Here are the mapping files:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
                                   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class
    name="test.common.domain.BulletinBoardEntry"
    table="bbd_cnt" polymorphism="explicit"
>

    <id
        name="id"
        type="java.lang.String" length="32" unsaved-value="null">
      <column name="bbd_ent_id" sql-type="char(32)" not-null="true" />       
        <generator class="uuid.hex" />
    </id>

    <property
        name="subject"
        type="java.lang.String" length="255">
        <column name="bbd_sbj" not-null="true"/>
    </property>
       
    <many-to-one name="bulletinBoard" class="test.common.domain.BulletinBoard">
           <column name="bbd_id" sql-type="char(32)" />
    </many-to-one>
   
    <property name="content" type="text" not-null="true">
         <column name="content" sql-type="CLOB(256K)"/>
     </property>
     
  <set name="viewedBy" table="bbd_ent_vwd"
         cascade="save-update" lazy="true">
         <key>
            <column name="bbd_ent_id" sql-type="char(32)"/>
         </key>
         <many-to-many class="test.common.domain.User" >
            <column name="usr_id" sql-type="varchar(32)"/>
         </many-to-many>
   </set> 
     
   <property name="auditInfo" type="test.common.domain.AuditInfoType">
           <column name="lst_upd_ts"/>
           <column name="crt_ts"/>
           <column name="upd_usr_id" sql-type="varchar(32)" length="32"/>
           <column name="crt_usr_id" sql-type="varchar(32)" length="32"/>
   </property>
   
</class>

<class
    name="test.common.domain.BulletinBoardEntryInfo"
    table="bbd_cnt"
>

    <id
        name="id"
        type="java.lang.String" length="32" unsaved-value="null">
      <column name="bbd_ent_id" sql-type="char(32)" not-null="true" />       
        <generator class="uuid.hex" />
    </id>

    <property
        name="subject"
        type="java.lang.String" length="255">
        <column name="bbd_sbj" not-null="true"/>
    </property>
       
    <many-to-one name="bulletinBoard" class="test.common.domain.BulletinBoard">
           <column name="bbd_id" sql-type="char(32)" />
    </many-to-one>
   
  <set name="viewedBy" table="bbd_ent_vwd"
         cascade="save-update" lazy="true">
         <key>
            <column name="bbd_ent_id" sql-type="char(32)"/>
         </key>
         <many-to-many class="test.common.domain.User" >
            <column name="usr_id" sql-type="varchar(32)"/>
         </many-to-many>
   </set>     
   
   <property name="auditInfo" type="test.common.domain.AuditInfoType">
           <column name="lst_upd_ts"/>
           <column name="crt_ts"/>
           <column name="upd_usr_id" sql-type="varchar(32)" length="32"/>
           <column name="crt_usr_id" sql-type="varchar(32)" length="32"/>
   </property>
   
</class>
</hibernate-mapping>


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
                                   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class
    name="test.common.domain.User"
    table="users"
>
    <id name="id" type="string" unsaved-value="none">
            <column name="usr_id" sql-type="varchar(32)" length="32" not-null="true"/>
            <generator class="assigned"/>
        </id>
      <property name="firstName" type="string">
         <column name="fst_nam_tx" sql-type="varchar(30)" length="30"/>
      </property>
      
      <property name="lastName" type="string" >
         <column name="lst_nam_tx" sql-type="varchar(30)" length="30"/>
      </property>
      
      <property name="emailAddress" type="string">
         <column name="eml_adr_tx" length="50"/>
      </property> 
       
      <set name="trackings" table="tracking"
         cascade="all" inverse="true" lazy="true">
         <key column="usr_id"/>
         <one-to-many class="test.common.domain.Tracking"/>
      </set>
      
<set name="formsWhereAuthor" table="form_authors"
         cascade="save-update" lazy="true">
         <key>
            <column name="usr_id" sql-type="char(32)"/>
         </key>
         <many-to-many class="test.common.domain.Form" >
            <column name="frm_id" sql-type="varchar(32)"/>
         </many-to-many>
   </set>   
    <set name="bulletinBoardsWhereReader" table="bbd_readers"
         cascade="save-update" lazy="true">
         <key>
            <column name="usr_id" sql-type="varchar(32)"/>
         </key>
         <many-to-many class="test.common.domain.BulletinBoard" >
            <column name="bbd_id" sql-type="char(32)"/>
         </many-to-many>
   </set> 
   <set name="viewedEntries" table="bbd_ent_vwd"
         cascade="save-update" lazy="true">
         <key>
            <column name="usr_id" sql-type="varchar(32)"/>
         </key>
         <many-to-many class="test.common.domain.BulletinBoardEntry" >
            <column name="bbd_ent_id" sql-type="char(32)"/>
         </many-to-many>
   </set>                     
</class>
</hibernate-mapping>
[/code]

_________________
- Brian


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.