Hey ... a blank forum ;-)
To open my question, first parts of the code:
Code:
<hibernate-mapping>
<class name="Order" table="ORDERS">
<id column="ID" name="key" type="long">
<generator class="sequence"/>
</id>
<property column="PRODUCTION_ORDER_NR" length="8" name="productionOrderNr" type="string"/>
<many-to-one name="orderStatus" class="OrderStatus" column="OSE_ID" outer-join="true"/>
<set name="orderStatusRealisations" table="ORDER_STATUS_REALISATIONS" sort="natural">
<key column="OER_ID"/>
<one-to-many class="OrderStatusRealisation"/>
</set>
</class>
<class name="OrderStatusRealisation" table="ORDER_STATUS_REALISATIONS">
<id column="ID" name="key" type="long">
<generator class="sequence"/>
</id>
<property column="DATE_REALISED" name="dateRealised" type="timestamp"/>
<property column="OER_ID" name="orderId" type="long"/>
<many-to-one name="orderStatus" column="OSE_ID" class="OrderStatus"/>
</class>
<class name="OrderStatus" table="ORDER_STATUSES">
<id column="ID" name="key" type="long">
<generator class="sequence"/>
</id>
<property column="ORDER_STATUS_CODE" length="5" name="orderStatusCode" not-null="true" type="string"/>
<property column="DESCRIPTION" length="30" name="description" not-null="true" type="string"/>
</class>
</hibernate-mapping>
public class Order {
long key;
String productionOrderNr;
OrderStatus orderStatus;
Set orderStatusRealisations;
}
public class OrderStatusRealisation {
long key;
Date dateRealised;
OrderStatus orderStatus;
}
public class OrderStatus {
long key;
String orderStatusCode;
String description;
}
In words:
You have a bunch of Orders, each holding a current State (orderStatus) and a history of old states using a Set of OrderStatusRealisation, each holding a orderState and a timestamp (dateRealised).
Now the problem is, I can't find in the documentation a way of expressing the select where I want to select the orders where the state (orderStatusCode) had a certain value in a defined period.
something like from Order o where o.orderStatusRealisations.orderStatus.orderStatusCode=1000
For some reason this gives me allways a NullPointerException - probably because orderStatusRealisations is a set ...
Is there a working way to express this query???
Thanks