Hi,
I am populating an object say Employer.
Like :
Code:
Criteria criteria = session.createCriteria(Employer.class,"employerData").add(Restrictions.eq("employerId", employerId));
criteria = criteria.createAlias("employerData.person", "person",CriteriaSpecification.LEFT_JOIN).setFetchMode("person", FetchMode.JOIN);
criteria = criteria.createAlias("person.personNames", "personNames",CriteriaSpecification.LEFT_JOIN).setFetchMode("personNames", FetchMode.JOIN);
criteria = criteria.createAlias("person.personAddresses", "personAddress",CriteriaSpecification.LEFT_JOIN).setFetchMode("personAddress", FetchMode.JOIN);
criteria = criteria.createAlias("personAddress.county", "personAddressCounty",CriteriaSpecification.LEFT_JOIN).setFetchMode("personAddressCounty", FetchMode.JOIN);
criteria = criteria.createAlias("personAddress.state", "personAddressState",CriteriaSpecification.LEFT_JOIN).setFetchMode("personAddressState", FetchMode.JOIN);
criteria = criteria.createAlias("employerData.personEmployerEmployeeAssocs", "employee",CriteriaSpecification.LEFT_JOIN).setFetchMode("employee", FetchMode.JOIN);
// This line below is the problem
criteria = criteria.add(Restrictions.isNull("employee.effectiveEndDate"));
employer = (Employer) criteria.uniqueResult();
While populating Employer object ,with several other details using joins if i put restriction (highlighted above) and if there are no records, the entire Employer object is returned Null ..
Any Solution to this ??
Thanks
Rajiv