-->
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.  [ 1 post ] 
Author Message
 Post subject: How to query on inherited properties (HQL)
PostPosted: Fri Aug 11, 2006 8:54 am 
Newbie

Joined: Wed Jul 26, 2006 7:49 am
Posts: 2
Location: Finland
Hello!

I have run into a little problem that I could not solve just by looking at the reference documentation. From the mapped class hierarchy below, I tried to fetch all DeviceBlock-instances that have no parent. As you can see, the parent property is inherited from the Component-class.

I used the following HQL-phrase:

"from DeviceBlock as db where db.parent is null"

However, this generates the wrong SQL as the parent-column has been placed in the DeviceBlock-table instead of the Component-table in the WHERE-clause.

What have I missed?

-Petter-


Hibernate version: 3.2.rc2

Mapping documents:
Code:
<class name="Component" table="component" abstract="true">
  <id name="UUID" type="com.paroc.ttp.common.hibernate.UUIDType">
    <generator class="com.paroc.ttp.common.hibernate.UUIDGenerator"/>
  </id>
  <version name="version" column="version" type="integer"  unsaved-value="null"/>
  <properties name="componentUniqueKey" unique="true" update="true" insert="true" optimistic-lock="true">
    <property name="name" column="name"   type="string" not-null="true"/>
    <many-to-one name="parent" column="parent" class="Component"/>
  </properties>
  <property name="description" column="description" type="string"/>
  <property name="hardware" column="hardware" type="string"/>
  <property name="comments" column="comments" type="string"/>
  <property name="revision" column="revision" type="string"/>
  <property name="infoMissing" column="infoMissing" type="yes_no"/>
  <property name="delivery" column="delivery" type="com.paroc.autosyst.device.domain.hibernate.ComponentDeliveryHT"/>
  <bag name="children" inverse="true" cascade="all" lazy="false" order-by="name">
    <key column="parent"/>
    <one-to-many class="Component"/>
  </bag>

  <joined-subclass name="DeviceBlock" table="deviceBlock">
    <key column="uuid"/>
    <property name="attention" column="attention" type="string"/>
    <property name="function" column="func" type="string"/>
    <property name="name" column="name" type="string" insert="false" update="false" unique="true" not-null="true"/>
     <!-- a few additional properties not included here -->
  </joined-subclass>
</class>

Name and version of the database you are using: FireBirdSQL 1.5

The generated SQL (show_sql=true):
Code:
select devicebloc0_.uuid as UUID0_, devicebloc0_1_.version as version0_, devicebloc0_1_.name as name0_, devicebloc0_1_.parent as parent0_, devicebloc0_1_.description as descript5_0_, devicebloc0_1_.hardware as hardware0_, devicebloc0_1_.comments as comments0_, devicebloc0_1_.revision as revision0_, devicebloc0_1_.infoMissing as infoMiss9_0_, devicebloc0_1_.delivery as delivery0_, devicebloc0_.attention as attention3_, devicebloc0_.func as func3_, devicebloc0_.name as name3_, devicebloc0_.project as project3_, devicebloc0_.section as section3_, devicebloc0_.software as software3_ from deviceBlock devicebloc0_ inner join component devicebloc0_1_ on devicebloc0_.uuid=devicebloc0_1_.UUID where devicebloc0_.parent is null


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.