-->
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: Duplicate column creation for subclass with a join
PostPosted: Wed Mar 21, 2007 8:31 am 
Newbie

Joined: Tue Mar 20, 2007 12:18 pm
Posts: 1
Location: Stafford, VA
I'm using hibernate v3 and have found a certain aspect of the created tables for subclasses declarations confusing. My mapping is as follows:

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

<hibernate-mapping auto-import="false">
   <class name="test.Component" table="component" >
        <id name="id" access="field">
            <generator class="native"/>
        </id>
        <discriminator column="type"/>
        <subclass name="test.Form" discriminator-value="form" lazy="false">
           <join table="form">
              <key column="id"/>
              <property name="description" />
              <many-to-one name="pe" access="field"
                 column="peid"
                 not-null="true"
              />
           </join>
        </subclass>
        <subclass name="test.TextField" discriminator-value="textfield" lazy="false"/>
    </class>
   
    <class name="test.PE" table="pe">
        <id name="id" access="field">
            <generator class="native"/>
        </id>
       <bag name="forms" access="field" cascade="all" inverse="true" lazy="false">
          <key column="peid"/>
          <one-to-many class="test.Form"/>
       </bag>
    </class>

</hibernate-mapping>


This mapping creates both a component table and form table as I would suspect but also creates duplicate 'peid' columns, one in form and the other in component. Event though code which uses this mapping appears to load and save correctly, shouldn't the column only be created in the form table? Is this just a side-affect of creating this kind of mapping? If so, is it documented someplace?


Top
 Profile  
 
 Post subject: Re: Duplicate column creation for subclass with a join
PostPosted: Sun Sep 12, 2010 4:11 am 
Newbie

Joined: Sun Sep 12, 2010 4:02 am
Posts: 1
I also have this problem
Code:
   <class name="WarehouseImpl" table="WAREHOUSE">
      <id name="id" column="ID">
         <generator class="native"/>
      </id>

      <bag name="warehousings" lazy="true" cascade="all,delete-orphan" inverse="true">
         <key column="WAREHOUSE"/>
         <one-to-many class="WarehousingImpl"/>
      </bag>
      <bag name="outsourceWarehousings" lazy="true" cascade="all,delete-orphan" inverse="true">
         <key column="WAREHOUSE"/>
         <one-to-many class="OutsourceWarehousingImpl"/>
      </bag>
   </class>


Code:
   <class name="DeliveryImpl" table="DELIVERY">
      <id name="id" column="ID">
         <generator class="native"/>
      </id>
      <many-to-one name="warehouse" column="WAREHOUSE" cascade="none" class="WarehouseImpl"/>
      <joined-subclass name="OutsourceDeliveryImpl" table="OUTSOURCE_DELIVERY">
         <key column="ID"/>
      </joined-subclass>
   </class>



in the table OUTSOURCE_DELIVERY,it will have a column:warehouse although there is a column: warehouse already in the table DELIVERY


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.