0 Replies Latest reply on Feb 19, 2008 3:35 PM by toolsky

    flex and multiple hibernate table joins

    toolsky
      Hi All,

      I was playing with the Flex and Java/hibernate to retrieve data. I managed to get the a simple table to display in Flex. However, when I tried to join to other tables; can't interate to the "Set", which contains the second table.

      Here's the hibernate mapping:
      <hibernate-mapping>
      <class name="com.questdiagnostics.hl7report.model.sql.Hl7Report" table="tb_hl7Report">
      <id name="reportID" column="reportID">
      <generator class="native"/>
      </id>
      <property name="fillerOrderNumber">
      <column name="fillerOrderNumber" />
      </property>
      <property name="reportStatus">
      <column name="reportStatus" />
      </property>

      <property name="prepareTime" type="timestamp" column="prepareTime"/>

      <set name="Hl7PIDData" table="tb_Hl7PID" lazy="false" cascade="all" inverse="true">
      <key column="reportID" not-null="true"/>
      <one-to-many class="com.questdiagnostics.hl7report.model.sql.Hl7PIDData"/>
      </set>

      </class>

      <query name="AllReports" ><![CDATA[
      from Hl7Report
      where reportID in (select max(a.reportID)
      from Hl7Report a, Hl7PIDData d
      where a.reportID=d.PIDDataPK.reportID and
      a.reportStatus in ('REPORT')
      group by a.fillerOrderNumber)
      ]]></query>


      <hibernate-mapping>
      <class name="com.questdiagnostics.hl7report.model.sql.Hl7PIDData" table="tb_Hl7PID">
      <composite-id name="PIDDataPK" class="com.questdiagnostics.hl7report.model.sql.Hl7PIDDataPK">
      <key-property name="reportID" column="reportID"/>
      <key-property name="setIDPID" column="setIDPID"/>
      </composite-id>

      <property name="patientIDInternalID">
      <column name="patientIDInternalID" />
      </property>

      Here's the Flex Managed Object:
      [Bindable]
      [RemoteClass(alias="com.questdiagnostics.hl7report.model.sql.Hl7Report")]
      public class Hl7Report
      {

      public function Hl7Report() {}

      public var reportID:int;

      public var fillerOrderNumber:String="";

      public var reportStatus:String="";

      public var prepareTime:Date;

      public var hl7PIDData:ArrayCollection;

      }

      flex/data-management-config.xml input:


      <destination id="hl7report.hibernate">
      <adapter ref="java-dao" />
      <properties>
      <use-transactions>true</use-transactions>
      <source>flex.data.assemblers.HibernateAssembler</source>
      <scope>application</scope>
      <metadata>
      <!--This is the unique identifier from the hibernate-entity bean -->
      <identity property="reportID"/>
      </metadata>
      <network>
      <session-timeout>20</session-timeout>
      <paging enabled="false" pageSize="10" />
      <throttle-inbound policy="ERROR" max-frequency="500"/>
      <throttle-outbound policy="REPLACE" max-frequency="500"/>
      </network>
      <server>
      <hibernate-entity>com.questdiagnostics.reportgenerator.model.sql.tb_hl7Report</hibernate- entity>
      <fill-method>
      <name>fill</name>
      <params>java.util.List</params>
      </fill-method>
      <fill-configuration>
      <use-query-cache>false</use-query-cache>
      <allow-hql-queries>true</allow-hql-queries>
      </fill-configuration>
      </server>
      </properties>
      </destination>

      I'm trying to ge to the hl7PIDData collection.

      Is there some solid good examples, which shows how to access multiple tables without doing into 2 calls to the hibernate by passing the reportid?

      Thanks in advance.