Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" 
   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
   
<hibernate-mapping package="DataModel">
   <class name="AttributeValue" table="REF_ATTR_VALUE" lazy="true">
      <meta attribute="class-description" >
         Attribute value base class. Its generalization provides values of all supported types.
      </meta>
      <id name="id" type="int" column="ID" >
         <generator class="native" />
      </id>
      <property name="valueType" column="VALUETYPE" type="java.lang.String" length="1" />
      <joined-subclass name="BlobValue" table="BLOBVALUE" lazy="true">
         <meta attribute="class-description">
            AttrValue extension. Provides {@link java.sql.Blob} value.
         </meta>
         <key column="VALUE_ID"/>
         <property name="blobvalue" type="de.systemagmbh.stationsdbWWW.DataModel.BinaryBlobType" column="BLOBVALUE" 
            length="2147483647" />
      </joined-subclass>
      <joined-subclass name="BoolValue" table="BOOLVALUE" lazy="true">
         <meta attribute="class-description">
            AttrValue extension. Provides {@link java.lang.Boolean} value.
         </meta>
         <key column="VALUE_ID"/>
         <property name="boolvalue" type="boolean" column="BOOLVALUE" length="1" />
      </joined-subclass>
      <joined-subclass name="CalcValue" table="CALCVALUE" lazy="true">
         <meta attribute="class-description">
            AttrValue extension. Provides calculated value based on SQL expression.
         </meta>
         <key column="VALUE_ID"/>
         <property name="sqlexpression" type="java.lang.String" column="SQLEXPRESSION" 
            length="1000" />
      </joined-subclass>
      <joined-subclass name="FloatValue" table="FLOATVALUE" lazy="true">
         <meta attribute="class-description">
            AttrValue extension. Provides {@link java.lang.Double} value.
         </meta>
         <key column="VALUE_ID"/>
         <property name="floatvalue" type="float" column="FLOATVALUE" length="10" />
      </joined-subclass>
      <joined-subclass name="IntValue" table="INTVALUE" lazy="true">
         <meta attribute="class-description">
            AttrValue extension. Provides {@link java.lang.Long} value.
         </meta>
         <key column="VALUE_ID"/>
         <property name="intvalue" type="int" column="INTVALUE" length="10" />
      </joined-subclass>
      <joined-subclass name="ListValue" table="LISTVALUE" lazy="true">
         <meta attribute="class-description">
            AttrValue extension. Provides value based on selected list index or indices.
         </meta>
         <key column="VALUE_ID" />
         <property name="listName" type="string" column="LIST_NAME" length="50" />
         <property name="listtype" type="string" column="LISTTYPE" length="1" />
         <set name="listValuesStandard" cascade="none" sort="natural" table="REF_LIST_VALUE_STANDARD">
            <key column="LIST_ID"/>
            <many-to-many class="ListValuesStandard" column="LIST_VALUE_STANDARD_ID"/>
         </set>
         <set name="listValuesSelect" cascade="all" >
            <key column="SEL_LIST_VALUE" foreign-key="VALUE_ID"/>
            <one-to-many class="ListValuesSelect"/>
         </set>
      </joined-subclass>
      <joined-subclass name="StringValue" table="STRINGVALUE" lazy="true">
         <meta attribute="class-description">
            AttrValue extension. Provides {@link java.lang.String} value.
         </meta>
         <key column="VALUE_ID"/>
         <property name="stringvalue" type="java.lang.String" column="STRINGVALUE" length="250" />
      </joined-subclass>
   </class>
</hibernate-mapping>
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
    
<hibernate-mapping package="DataModel">
<class name="Attribute" table="ATTRIBUTE">
    <id name="id" type="int" column="ID">
        <generator class="native" />
    </id>
   <property name="version" type="int" column="VERSION" length="10" />
   <property name="date" type="java.sql.Timestamp" column="DATUM" length="23" />
   <property name="username" type="java.lang.String" column="USERNAME" length="50" />
   <property name="state" type="java.lang.String" column="STATE" not-null="true" length="1" />
   <property name="firstAssignedId" type="int" column="FIRST_ASSIGNED_ID" length="10" />
    <!-- associations -->
   <many-to-one name="parentAttribute" class="Attribute" column="PARENT_ATTRIB_ID" 
         cascade="none" not-null="false" outer-join="true" /> 
    <!-- bi-directional many-to-one association to AttributeValue -->
   <many-to-one name="attributeValue" class="AttributeValue" not-null="true" cascade="all">
      <column name="VALUE_ID" />
   </many-to-one>
    <!-- bi-directional many-to-one association to AttributeTemplate -->
   <many-to-one name="attributeTemplate" class="AttributeTemplate" not-null="true" cascade="none">
      <column name="ATTR_TEMPLATE_ID" />
   </many-to-one>
   
    <!-- bi-directional many-to-one association to StationElement -->
   <many-to-one name="stationElement" class="StationElement" not-null="true" cascade="none" >
      <column name="PARENT_ELEM_ID" />
   </many-to-one>
    <!-- bi-directional one-to-many association to ChildAttributes elements -->
   <set name="childAttributes" lazy="true" inverse="true" outer-join="true" >
      <key>
          <column name="PARENT_ATTRIB_ID" not-null="false" />
      </key>
      <one-to-many class="Attribute" />
   </set>
</class>
</hibernate-mapping>
I want to write an HQL query like:
select a from Attribute as a 
join a.attributeValue as av 
where ((IntValue)av).intvalue=1
or
select a from Attribute as a 
join a.attributeValue as av 
join av.IntValue as i 
where i.intvalue=1
or
select a from Attribute as a 
join a.IntValue as i 
where i.intvalue=1
How to I do this right?
Because of AttributeValue.valueType i always knows witch type I have.
Thx Uwe