hi there,
I hope I did not oversee
any FAQ or postings in asking the following:
I have this relations:
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