Hallo!
Ich habe ein Problem bei einem JOIN zwischen zwei Tabellen, wobei eine Tabelle einen Compound Key hat. Die Mappings sehen folgendermaßen aus:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="RuleResult" table="ruleresult" catalog="earlywarner">
<composite-id name="id" class="RuleResultId">
<key-property name="ruleId" type="integer">
<column name="Rule_ID" />
</key-property>
<key-property name="evaluationDayId" type="date">
<column name="Evaluation_Day_ID" length="10" />
</key-property>
<key-property name="dwhStatus" type="string">
<column name="DWH_Status" length="2" />
</key-property>
<key-property name="lastModifiedTs" type="timestamp">
<column name="Last_Modified_TS" length="19" />
</key-property>
</composite-id>
<property name="ruleStatus" type="short">
<column name="Rule_Status" not-null="true" />
</property>
<property name="executionStartTime" type="timestamp">
<column name="Execution_Start_Time" length="19" />
</property>
<property name="executionEndTime" type="timestamp">
<column name="Execution_End_Time" length="19" />
</property>
<property name="executionDayId" type="date">
<column name="Execution_Day_ID" length="10" not-null="true" />
</property>
<property name="result" type="double">
<column name="Result" precision="10" not-null="true" />
</property>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="RuleRecipientMapping" table="rulerecipientmapping" catalog="earlywarner">
<id name="ruleRecipientMappingId" type="integer">
<column name="Rule_Recipient_Mapping_ID" />
<generator class="increment"></generator>
</id>
<property name="ruleId" type="integer">
<column name="Rule_ID" not-null="true" />
</property>
<property name="recipientId" type="integer">
<column name="Recipient_ID" not-null="true" />
</property>
</class>
</hibernate-mapping>
Nun möchte ich die beiden Tabellen folgendermaßen joinen:
String hsql = "select rr.Rule_ID, rr.Rule_Status, rr.Evaluation_Day_ID, rr.Result from RuleResult as rr, RuleRecipientMapping as rrm where rr.Rule_ID=rrm.Rule_ID and rrm.Recipient_ID=" + _recipient.getRecipientId() + " and rr.Evaluation_Day_Id='" + _date + "' and rr.DWH_Status='AC'";
Query query = session.createQuery(hsql);
Ich bekomme die folgende Fehlermeldung:
could not resolve property: Rule_ID of: RuleResult
was mir auch einleuchtet, da Rule_ID Teil des Compound Key ist. Wie würde man das am besten lösen? Danke im voraus,
Tobi
|