Hi All,
I got NullPointerException when I call sql server storedprocedure from hibernate mapping. I am sending my code, plz do provide a solution to my problem
//mapping code
<sql-query name="selectAllEmployees_SP" callable="true">
<return alias="Employee" class="Employee">
<return-property name="empId" column="EmpId"/>
<return-property name="empName" column="EmpName"/>
<return-property name="empSal" column="EmpSal"/>
<return-property name="empAdd" column="EmpAdd"/>
<return-property name="id" column="id"/>
</return>
{call selectAllEmployees()}
</sql-query>
//end of mapping code
The following is the mapping for Employee class
<class name="Employee" table="Employee">
<id name="id" type="int">
</id>
<property name="empId">
<column name="EmpId" />
</property>
<property name="empName">
<column name="EmpName"/>
</property>
<property name="empSal">
<column name="EmpSal"/>
</property>
<property name="empAdd">
<column name="EmpAdd"/>
</property>
</class>
calling from my program:
trans=session.beginTransaction();
System.out.println("before calling procedure");
List offerq=session.getNamedQuery("selectAllEmployees_SP").list();
Iterator offerit=offerq.iterator();
while(offerit.hasNext())
{
Employee o=(Employee)offerit.next();
System.out.println("emp name from procedure=="+o.getEmpName()); //exception in this line
}
trans.commit();
session.close();
Do I miss anything in this code?
Thanx in advance
|