I’m trying to load a record with its related object. But when criteria condition applied, if the related object is not found, then the result model will be null. Please look at my code below:
I want to get the post with related ‘projectCrews’. The problem is when the post doesn’t have related ‘projectCrews’ it won’t appear in the result model.
EDIT: Just saw that LEFT OUTER JOIN seems to be the default already, so the problem may be the condition. If you don’t have a post associated with a “projectCrew” the condition “isUploaderApprove=1 AND isCrewApprove=1” might implicitly fail cause these values are empty too (?). Because of the left join the values for isUploaderApprove and isCrewApprove will be NULL if there is no assignment so you might have to include that in an OR statement
isUploaderApprove=1 AND isCrewApprove=1 OR (isUploaderApprove IS NULL AND isCrewApprove IS NULL)