-->
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.  [ 7 posts ] 
Author Message
 Post subject: query a joined subclass using root class property in where..
PostPosted: Mon Oct 20, 2003 8:40 am 
Newbie

Joined: Thu Oct 16, 2003 4:55 am
Posts: 9
Location: Berlin, Germany
hi there,

I hope I did not oversee any FAQ or postings in asking the following:

I have this relations:

Image

I want to query all Catalogs of customers in a specific zipcode area:

select o from catalog as o where o.customer.address.zipcode = '12345'

Here I get an SQL error 'unknown column name', because I get the following SQL (I cleaned it up) from hibernate:
select *
from CATALOG cat, CUSTOMER cust , ADRESS adr
where cat.customer_id = cust.id and cust.address_id = adr.id

obviously the root class ORGANISATION, that is actually holding the address is not joined to customer and instead the column address_id is aspected in CUSTOMER.

this is the mapping:
Code:
  <class name="Catalog" table="CATALOG">
    <id name="id">
        <generator class="increment"/>
    </id>
    ....

   <many-to-one name="customer" column="customer_id"
           class="Customer"
   />

  </class>

  <class name="Organisation" table="ORGANISATION">
    <id name="id">
        <generator class="increment"/>
    </id>
    ....

   <many-to-one name="address" column="address_id"
           class="Address"
   />

       <joined-subclass name="Customer" table="CUSTOMER">
            <key column="id"/>
           ....
       </joined-subclass>
  </class>

  <class name="Address" table="ADDRESS">
    <id name="id">
        <generator class="increment"/>
    </id>
    <property name="zipcode"/>
  </class>

I just could not find any hints to that problem and hope for help.
thanx in advance
:olli


Top
 Profile  
 
 Post subject: simple but ...
PostPosted: Mon Oct 20, 2003 11:33 am 
Regular
Regular

Joined: Tue Sep 16, 2003 11:35 am
Posts: 93
Location: San Francisco, CA
I don't see anything obvious ... what version of Hibernate are you using?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 20, 2003 11:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I think you are using an obsolete version of Hibernate, which has a bug like this.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 20, 2003 11:50 am 
Newbie

Joined: Thu Oct 16, 2003 4:55 am
Posts: 9
Location: Berlin, Germany
I'm using 2.0.3, the recommended Version from about 1 and a half weeks ago.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 20, 2003 11:52 am 
Newbie

Joined: Thu Oct 16, 2003 4:55 am
Posts: 9
Location: Berlin, Germany
after some more testing:
I found out, that the "filtering" works fine, if I just do:

select o from Customer o where o.adress.zipcode = '12345'

the error message just shows up, when the customer is inside another object.

got any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 20, 2003 11:53 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
ok then, submit a test main() method to JIRA.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 20, 2003 11:55 am 
Newbie

Joined: Thu Oct 16, 2003 4:55 am
Posts: 9
Location: Berlin, Germany
roger. will do so tomorrow.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.