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: Subclass one-to-one - Unknown column issue
PostPosted: Sun Feb 28, 2010 11:05 pm 
Newbie

Joined: Thu Jan 01, 2009 10:57 am
Posts: 7
Hi Team,

Below are my pojos

Code:
class SuperA{}

abstract class SubA extends SuperA{}

class SubB extends SubA{
   SubC subC;
}

class SubC extends SubA{
   SubB subB;
}


And below are my mapping files

Code:
<hibernate-mapping>
   <class name="SuperA" table="SuperA">
      <id column="ID" name="id" type="java.lang.Long">
         <generator class="increment" />
      </id>
      <discriminator column="DISCRIMINATOR" force="false"
         insert="true" length="30" not-null="true" type="java.lang.String" />
   </class>
</hibernate-mapping>

<hibernate-mapping>
   <subclass abstract="true" discriminator-value="SubA"
      extends="SuperA" name="SubA"
      select-before-update="false">
      <join fetch="select" table="SubA">
         <key on-delete="cascade">
            <column name="ID" />
         </key>
      </join>
   </subclass>
</hibernate-mapping>

<hibernate-mapping>
   <subclass discriminator-value="SubB"
      extends="SubA" name="SubB"
      select-before-update="false">
      <one-to-one class="SubC"
         cascade="all" name="subC" property-ref="subB" />
      <join fetch="select" table="SubB">
         <key on-delete="cascade">
            <column name="ID" />
         </key>
      </join>
   </subclass>
</hibernate-mapping>

<hibernate-mapping>
   <subclass discriminator-value="SubC"
      extends="SubA" name="SubC"
      select-before-update="false">
      <join fetch="select" table="SubC">
         <key on-delete="cascade">
            <column name="ID" />
         </key>
      </join>
      <many-to-one cascade="save-update" class="SubB"
         name="subB" not-null="true">
         <column name="SUB_B_ID" />
      </many-to-one>
   </subclass>
</hibernate-mapping>


Now i am trying "from SubB" HQL and it throws the below error.
Unknown column 'subc_1_.SUB_B_ID' in 'where ......

If i add the SUB_B_ID column in SuperA and set the same value as in SubC then all are working fine. Basically when "from SubB" HQL is compiled to sql query it is not joining SubA and SubC for the one-to-one mapping. Even if i change the one-to-one mapping to one-to-many i get into same issue.

Please help me to find out a solution. I can not change the mapping drastically, because of so many other dependencies. But i can change it if this won't work.

Thanks for your help.

Navaneeth


Top
 Profile  
 
 Post subject: Re: Subclass one-to-one - Unknown column issue
PostPosted: Mon Mar 01, 2010 10:34 pm 
Newbie

Joined: Thu Jan 01, 2009 10:57 am
Posts: 7
Hi Team,

Could you please show me some pointer where i can get the details to fix this.

Thanks


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.