views:

113

answers:

1

Hi,

I have two classes SystemInvitation and User. User has a property called Email and SystemInvitation has a property called InviteesEmailAddress. There is no relationship in the domain between these properties.

Is it possible using the Criteria API to produce a query like:

select si.InviteesEmailAddress , si.Identifier , case when u.id is null then 0 else 1 end as UserExists from SystemInvitation si left outer join [User] u on u.Email = si.InviteesEmailAddress

?

Thanks!

A: 

You should map the InviteesEmailAddress column in the mapping for SystemInvitation using something like this:

<many-to-one name="InviteesEmailAddress" fetch="join" class="User"
    column="Email" cascade="none" not-found="ignore" />
Kevin Albrecht