-->
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: property located in wrong table in a subclass
PostPosted: Mon Mar 17, 2008 3:25 pm 
Newbie

Joined: Tue Sep 25, 2007 6:43 am
Posts: 16
Hi,

nh, somewhere close to the trunk.

I have a table per subclass inheritance mapping.

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
   <class name="ShoppingCartItem"
             table="ShoppingCartItem"
             lazy="true">
      <id name="Id"
            column="ShoppingCartItemID"
            unsaved-value="0">
         <generator class="identity" />
      </id>
      <many-to-one name="Cart"
                         column="ShoppingCartID"
                         not-null="true"
                         class="ShoppingCart"/>

      <joined-subclass name="ShoppingCartProductItem"
                               table="ShoppingCartProductItem">
         <key column="ShoppingCartItemID"/>
         <many-to-one name="Product"
                   column="ProductID"
                   not-null="false"
                   class="Product"
                   cascade="none"/>
         <property name="Option"
                     column="[Option]" />
      </joined-subclass>

      <joined-subclass name="ShoppingCartProductSetItem"
                               table="ShoppingCartProductSetItem">
         <key column="ShoppingCartItemID"/>
         <many-to-one name="ProductSet"
                   column="ProductSetID"
                   not-null="false"
                   class="ProductSet"
                   cascade="none"/>
      </joined-subclass>

   </class>
   
</hibernate-mapping>


I get lots of 'Invalid column name 'ShoppingCartID'.' exceptions, because NH looks for this column in the wrong table.... The generated sql is like this:
Code:
SELECT     productite0_.ShoppingCartID AS Shopping4_1_, productite0_.ShoppingCartItemID AS Shopping1_1_, productite0_.ShoppingCartItemID AS Shopping1_39_0_,
                      productite0_1_.ShoppingCartID AS Shopping5_39_0_, productite0_.ProductID AS ProductID40_0_
FROM         ShoppingCartProductItem AS productite0_ INNER JOIN
                      ShoppingCartItem AS productite0_1_ ON productite0_.ShoppingCartItemID = productite0_1_.ShoppingCartItemID
WHERE     (productite0_.ShoppingCartID = '9c8692bb-d829-4d89-94e7-9a5b00c4fd7d')


so it looks for the ShoppingCardId in the table productite0_, where it actually should look in productite0_1_. At least it seems to me that this is what I am telling NH to do.

Any help greatly appreciated!

Jan


Top
 Profile  
 
 Post subject: Re: property located in wrong table in a subclass
PostPosted: Wed Mar 19, 2008 1:24 pm 
Newbie

Joined: Tue Sep 25, 2007 6:43 am
Posts: 16
is this so obvious/am I so stupid or is there really no help for me??

:(


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.