title: Hibernate Mapping Two Tables to One Class
body: <p>I need to map two tables to a single class, having trouble figuring this out.  One table is ROOMS, the other is TRAINERS.  </p>
  
  <p>The ROOMS table:</p>
  
  <pre><code>OOC_UNIT_ID          NUMBER(6,0)
  OOC_START_DT         DATE
  OOC_START_TM         DATE
  OOC_DT_MOD           DATE
  OOC_USER_MOD         VARCHAR2(30 BYTE)
  OOC_END_DT           DATE
  OOC_END_TM           DATE
  OOC_REASON_TX        VARCHAR2(250 BYTE)
  OOC_RESERVED_FOR     VARCHAR2(30 BYTE)
  OOC_CLS_ID           NUMBER(9,0)
  OOC_TIMEFRAME        VARCHAR2(1 BYTE)
  OOC_WSD_CD           VARCHAR2(2 BYTE)
  OOC_TEAM_UNIT_ID     NUMBER(6,0)
  OOC_WSD_ACT_RMAT_ID  NUMBER(6,0)
  </code></pre>
  
  <p>TRAINERS table:</p>
  
  <pre><code>TRSC_ID                NUMBER(9,0) -- generated sequence
  TRSC_OOC_UNIT_ID       NUMBER(6,0)
  TRSC_OOC_START_DT      DATE
  TRSC_OOC_START_TM      DATE
  TRSC_OOC_RESERVED_FOR  VARCHAR2(30 BYTE)
  TRSC_TPOC_ID           NUMBER(6,0)
  TRSC_DT_CREATED        DATE
  TRSC_USER_CREATED      VARCHAR2(30 BYTE)
  TRSC_DT_MOD            DATE
  TRSC_USER_MOD          VARCHAR2(30 BYTE)
  TRSC_REMARKS           VARCHAR2(250 BYTE)
  TRSC_NOSHOW_REASON     VARCHAR2(100 BYTE)
  </code></pre>
  
  <p>Tables should be joined on <code>OOC_UNIT_ID=TRSC_OOC_UNIT_ID</code>, <code>OOC_START_DT=TRSC_OOC_START_DT</code> and <code>OOC_START_TM=TRSC_OOC_START_TM</code>.  </p>
  
  <p>Primary Key for ROOMS table is: <code>OOC_UNIT_ID, OOC_START_DT, OOC_START_TM</code>.  Primary Key for the TRAINERS table is: <code>TRSC_ID</code>.</p>
  
  <p>I need to query this data by <code>OOC_UNIT_ID</code>, <code>OOC_START_DT</code>, <code>OOC_START_TM</code>, <code>OOC_END_DT</code>, <code>OOC_END_TM</code> and <code>OOC_WSD_ACT_RMAT_ID</code>.  </p>
  
  <p>In SQL it might be something like:</p>
  
  <pre><code>SELECT * 
    FROM TRAINERS t, ROOMS r
   WHERE t.TRSC_OOC_UNIT_ID = r.OOC_UNIT_ID
     AND t.TRSC_OOC_START_DT = r.OOC_START_DT
     AND t.TRSC_OOC_START_TM = r.OOC_START_TM
     AND ...
  </code></pre>
  
  <p>I am using the ROOMS table elsewhere in the project and it is already mapped as a standalone object.  Would there be a way to utilize that as a sub-object on a TRAINERS object, or would it be easier to map these two tables into one flat object?  How would the mapping look?</p>
  
  <p>Thanks,
  Nick</p>