Hi
I am trying to execute stored procedure in SQL server 2000 but i get "Error reading resource: contact.hbm.xml". I followed Hibernate tutorial but it is still getting error.
below is my code
contact.hbm.xmlCode:
<class name="springapp.web.Event" table="EVENTS">
<id name="id" column="EVENT_ID">
<generator class="identity" />
</id>
<property name="title" type="string" column="TITLE" not-null="true"/>
<property name="date" type="date" column="EVENT_DATE" not-null="true"/>
<loader query-ref="getEventSP"></loader>
</class>
<sql-query name="getEventSP" callable="true">
<return alias="getEventSP" class="springapp.web.Event">
<return-property name="id" column="EVENT_ID"></return-property>
<return-property name="title" column="TITLE"></return-property>
<return-property name="date" column="EVENT_DATE"></return-property>
</return>
{ ? = call selectAllEmployments(?) }
</sql-query>
Event.java POJOCode:
public class Event implements Serializable{
private java.lang.Integer id;
private java.lang.String title;
private Date date;
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public java.lang.Integer getId() {
return id;
}
public void setId(java.lang.Integer id) {
this.id = id;
}
public java.lang.String getTitle() {
return title;
}
public void setTitle(java.lang.String title) {
this.title = title;
}
}
My main classCode:
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();
tx = session.beginTransaction();
Query query = session.getNamedQuery("getEventSP");
query.setInteger(0,1);
List<Event> books = query.list();
for (Iterator<Event> iter = books.iterator(); iter.hasNext();) {
Event book = iter.next();
System.out.println("last name===>"+book.getTitle());;
}
tx.commit();
My procedure
Quote:
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
ALTER Proc selectAllEmployments
--RETURn SYS_REFCURSOR
AS
--st_cursor SYS_REFCURSOR;
BEGIN
--OPEN st_cursor FOR
SELECT EMPLOYEE, EMPLOYER,
STARTDATE, ENDDATE,
REGIONCODE, EID, VALUE, CURRENCY
FROM EMPLOYMENT;
--RETURN st_cursor;
END
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
The above code gives me "Error reading resource: contact.hbm.xml" .Do hibernate require refcursor ?.