Hi
I'm kind of stumped with this. The Query.uniqueResult method is returning an Array of 'Object' rather than returning a single instance of the entity. Here is the query I'm firing:
Code:
qry = session.createQuery("from DealHistory dh" +
" left join fetch dh.dealDisclaimer dd" +
" left join fetch dh.dealSynopsis ds" +
" left join fetch dd.dealDisclaimerParties ddp" +
" left join fetch dh.dealTickler dt" +
" left join fetch dh.dealCgNote dcgn" +
" left join ddp.party p" +
" with p.startTime <= :asOfDate" +
" and p.endTime > :asOfDate" +
" where dd.startTime <= :asOfDate" +
" and dd.endTime > :asOfDate" +
" and ds.startTime <= :asOfDate" +
" and ds.endTime > :asOfDate" +
" and dt.startTime <= :asOfDate" +
" and dt.endTime > :asOfDate" +
" and dcgn.startTime <= :asOfDate" +
" and dcgn.endTime > :asOfDate" +
" and dh.dealKey = :dealKey"
);
qry.setInteger("dealKey", 211);
qry.setParameter("asOfDate", asOfDate);
Deal d = (Deal) qry.uniqueResult();
When this query runs, instead of getting a single Deal object I'm getting an Array with 2 elements which contains my Deal instance as the first element and the second element, null. I'm using and DB2 and have a sinking feeling that this has something to do with Hibernate-DB2 dialect handling rather than the query. However, I'm not sure.
The result Hibernate query which gets fired is this:
Code:
select
<many many fields populated by hibernate>
from
DEAL_HISTORY dealhistor0_
left outer join
DEAL_DISCLAIMER_HISTORY dealdiscla1_
on dealhistor0_.DEAL_KEY=dealdiscla1_.DEAL_KEY
left outer join
DEAL_DISCLAIMER_PARTY_HISTORY dealdiscla3_
on dealdiscla1_.DEAL_DISCLAIMER_KEY=dealdiscla3_.DEAL_DISCLAIMER_KEY
and dealdiscla3_.START_TIMESTAMP <= ?
and dealdiscla3_.END_TIMESTAMP > ?
left outer join
PARTY_HISTORY partyhisto6_
on dealdiscla3_.PARTY_KEY=partyhisto6_.PARTY_KEY
and (
partyhisto6_.START_TIMESTAMP<=?
and partyhisto6_.END_TIMESTAMP>?
)
left outer join
DEAL_SYNOPSIS_HISTORY dealsynops2_
on dealhistor0_.DEAL_KEY=dealsynops2_.DEAL_KEY
left outer join
DEAL_TICKLER_HISTORY dealtickle4_
on dealhistor0_.DEAL_KEY=dealtickle4_.DEAL_KEY
left outer join
DEAL_CG_NOTE_HISTORY dealcgnote5_
on dealhistor0_.DEAL_KEY=dealcgnote5_.DEAL_KEY
where
dealhistor0_.START_TIMESTAMP <= ?
and dealhistor0_.END_TIMESTAMP > ?
and dealdiscla1_.START_TIMESTAMP<=?
and dealdiscla1_.END_TIMESTAMP>?
and dealsynops2_.START_TIMESTAMP<=?
and dealsynops2_.END_TIMESTAMP>?
and dealtickle4_.START_TIMESTAMP<=?
and dealtickle4_.END_TIMESTAMP>?
and dealcgnote5_.START_TIMESTAMP<=?
and dealcgnote5_.END_TIMESTAMP>?
and dealhistor0_.DEAL_KEY=?
Can anybody offer any help on this one. This has had me really stumped.