Hi Everyone,
I'm having a problem and really need help...
Schema
Employee:
Code:
<class name="com.test.Employee" table="employee_table">
<id name="id" type="java.lang.Integer">
<column name="fid"/>
<generator class="assigned" />
</id>
<property name="id2" column="fid2" type="java.lang.Integer"/>
<many-to-one name="info" column="fid2" class="com.test.EmployeeInfo" insert="false" update="false"/>
// ...
</class>
EmployeeInfo:
Code:
<class name="com.test.EmployeeInfo" table="employee_info_table">
<id name="infoId" column="fid2" type="java.lang.Integer">
<generator class="assigned" />
</id>
<set name="educations" lazy="false">
<key column="fid2" />
<one-to-many class="com.test.Education" />
</set>
// ...
</class>
Education:
Code:
<class name="com.test.Education" table="education_table">
<composite-id>
<key-property name="infoId" column="fid2" length="6" type="java.lang.Integer"/>
<key-property name="educationSequenceNumber" column="seq" length="4" type="java.lang.Short"/>
</composite-id>
<set name="specialities" lazy="false">
<key>
<column name="fid2"/>
<column name="edsq"/>
</key>
<one-to-many class="com.test.Speciality" />
</set>
// ...
</class>
Speciality:
Code:
<class name="com.test.Speciality" table="speciality_table">
<composite-id>
<key-property name="infoId" column="fid2" length="6" type="java.lang.Integer"/>
<key-property name="educationSequenceNumber" column="edsq" length="4" type="java.lang.Short"/>
<key-property name="specialitySequenceNumber" column="seq" length="4" type="java.lang.Short"/>
</composite-id>
// ...
</class>
I do:
Code:
Employee employee = (Employee) hSession.load(Employee.class, new Integer(30));
// employee has info, info has educations, some educations have specialities
for (Iterator iter = employee.getInfo().getEducations().iterator(); iter.hasNext(); ){
Education educ = (Education) iter.next();
Set spec = educ.getSpecialities();
system.out.println(spec.isEmpty());
// works fine for educations that have specialities
// but fails (exceptions) on education that don't have specialities (see below)
}
Exception:
Code:
java.lang.NullPointerException
at net.sf.hibernate.collection.Set.isEmpty(Set.java:115)
at org.apache.jsp._index._jspService(_index.java:174)
at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:344)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java:683)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java:781)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:76)
...
similar exception if I try toString(), size(), etc. on that Set...
Thanks