Help!
I have a named query that lives in my .hbm.xml file, and it looks like
<query name="donors.by.donorLevel"><![CDATA[
SELECT
Donor.DonorId,
Donor.FirstName,
Donor.LastName,
Donor.CompanyName,
Donor.Address1,
Donor.Address2,
Donor.City,
Donor.State,
Donor.PostalCode,
Donor.Email,
Donor.PhoneNumber,
Donor.MemberSince
FROM
Donor
LEFT OUTER JOIN (
SELECT
DonorID,
SUM(DonationAmount) AS DonationTotal
FROM
Donation
GROUP BY
DonorID
) DonorDonation
ON Donor.DonorId = DonorDonation.DonorId
LEFT OUTER JOIN DonorLevel
ON ISNULL(DonationTotal, 0) BETWEEN DonorLevel.LowerBoundAmount
AND DonorLevel.UpperBoundAmount
WHERE
DonorLevel.DonationLevelId = ?]]>
</query>
But i'm getting an error, it wont even intitialize. It says there is an error on the LEFT OUTER JOIN ( SELECT...
Any ideas? I'm not writing this in HQL, this is straight up SQL.
Help!
I have a named query that lives in my .hbm.xml file, and it looks like
<query name="donors.by.donorLevel"><![CDATA[
SELECT
Donor.DonorId,
Donor.FirstName,
Donor.LastName,
Donor.CompanyName,
Donor.Address1,
Donor.Address2,
Donor.City,
Donor.State,
Donor.PostalCode,
Donor.Email,
Donor.PhoneNumber,
Donor.MemberSince
FROM
Donor
LEFT OUTER JOIN (
SELECT
DonorID,
SUM(DonationAmount) AS DonationTotal
FROM
Donation
GROUP BY
DonorID
) DonorDonation
ON Donor.DonorId = DonorDonation.DonorId
LEFT OUTER JOIN DonorLevel
ON ISNULL(DonationTotal, 0) BETWEEN DonorLevel.LowerBoundAmount
AND DonorLevel.UpperBoundAmount
WHERE
DonorLevel.DonationLevelId = ?]]>
</query>
But i'm getting an error, it wont even intitialize. It says there is an error on the LEFT OUTER JOIN ( SELECT...
Any ideas? I'm not writing this in HQL, this is straight up SQL.
Help!