I have a many-to-one association which can also be nullable.
[code] <many-to-one name="secondWorkLocation" class="com.hibernate.SecondWorkLocation" not-null="false" fetch="select" not-found="ignore"> <column name="LOCATION_ID" precision="22" scale="0"/> </many-to-one> [/code]
Wheneven my hibernate query (below) tries to retrieve the records it works for a employee record which has secondworklocation but fails to return any data when there is no second work location.
[code] List<Employees> results = null; DetachedCriteria crit = DetachedCriteria.forClass(Employees.class); crit.add(Restrictions.eq("employeeId", employee.getEmployeeId())); results = getHibernateTemplate().findByCriteria(crit); [/code]
[code] CREATE TABLE "TESTDB"."EMPLOYEES" (... "LOCATION_ID" NUMBER(38 , 0)) ALTER TABLE "TESTDB"."EMPLOYEES" ADD CONSTRAINT "EMPLOYEES_FK1" FOREIGN KEY ("LOCATION_ID") REFERENCES "TESTDB"."SECOND_WORK_LOCATION" ("LOCATION_ID") [/code]
Is there any syntactic error in my many to one mapping ?
|