Are you sure?

Using your mappings (except I use a GUID.COMB generator instead of
Native) My SQL equivalent is:

select audit0_.Id as Id0_, audit0_.Active as Active0_,
audit0_.DateAudited as DateAudi3_0_
from audits audit0_ inner join audit_auditTypes audittypes1_
on audit0_.Id=audittypes1_.auditId
inner join audittypes audittype2_ on
audittypes1_.auditTypeId=audittype2_.Id
where audittype2_.Id in (@p0)


I'm using NH 2.1.2. I seem to recall that NH 1.2 produces different
SQL similar to yours but it still produces the right result as it
JOINs on the WHERE clause instead of via INNER JOINS (don't quote me
though - we still use NH 1.2 and I'm pretty sure the above works but I
haven't looked at it for a while)

The above SQL might well produce duplicates but usually I just add a
DISTINCT clause to the HQL

SELECT DISTINCT au FROM Audit au JOIN au.AuditTypes at WHERE at.id IN
(:ids)

which produces

select distinct audit0_.Id as Id0_, audit0_.Active as Active0_,
audit0_.DateAudited as DateAudi3_0_
from audits audit0_ inner join audit_auditTypes audittypes1_ on
audit0_.Id=audittypes1_.auditId
inner join audittypes audittype2_ on
audittypes1_.auditTypeId=audittype2_.Id
where audittype2_.Id in (@p0)

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.


Reply via email to