I have the following HQL query that is attempting to return 2 object instances as well as an aggregate count based upon a 3rd object instance.
SELECT
client,
clientCampaign,
count( formData )
FROM
FormData as formData
JOIN formData.deliveryResults as deliveryResults
JOIN formData.leadForm as leadForm
JOIN leadForm.campaignForms as campaignForms
JOIN campaignForms.clientCampaignForms.clientCampaign as clientCampaign
JOIN clientCampaign.client as client
WHERE
client.id = ?
GROUP BY
client.id, clientCampaign.id
The results always return with the clientCampaign instance being null. However, if I remove the count( formData ) line from the SELECT clause, the clientCampaign instance is no longer null. I have checked the data set and there are 5 total formData records ... 3 for one clientCampaign and 2 for another. So, I believe this query should be returning 2 results, both with non-null clientCampaign instances.
Can anybody tell if there is something obvious I am missing here?
TIA