Hi,
I have a stored proc as given following:
procedure get_all_users_report( PO_RESULT OUT gt_cursor
)
as
v_insert varchar(4000);
begin
INSERT INTO tmp_usersreport(userinfo_id , username, isactive)
(
SELECT userinfo_id , username, isactive
FROM userinfo
WHERE isactive = 1
);
open PO_RESULT for
select username from tmp_usersreport;
end get_all_users_report;tmp_usersreport
tmp_usersreport is a global temp table defined in ORACLE DB.
My Hibernate mapping is called sp.hbm.xml:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="UserReport" table="tmp_usersreport">
<property name="username" column="username"/>
</class>
<sql-query name="test_SP" callable="true">
<return alias="UserReport" class="UserReport">
</return>
{? = call test_pkg.get_all_users_report(?) }
</sql-query>
</hibernate-mapping>
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbcracle:thin:@localhost:1521:XE</property>
<property name="hibernate.connection.username">System</property>
<property name="hibernate.connection.password">
test</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="show_sql">false</property>
<mapping resource="sp.hbm.xml"/>
</session-factory>
</hibernate-configuration>
My return DTO is:
public class UserReport implements java.io.Serializable{
String username;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
Java Code to call stored proc:
List<UserReport> users;
try
{
Session sessionObj = HibernateUtil.currentSession();
Transaction tx = sessionObj.beginTransaction();
users = sessionObj.getNamedQuery("test_SP").list();
System.out.println(users.size());
Iterator it = users.iterator();
while(it.hasNext())
{
UserReport menu = (UserReport) it.next();
}
HibernateUtil.closeSession();
Exception is:
Initial SessionFactory creation failed.org.hibernate.MappingException: Could not read mappings from resource: sp.hbm.xml
Exception in
thread "main" java.lang.ExceptionInInitializerError
at HibernateUtil.<clinit>(HibernateUtil.java:17)
at test4.test(test4.java:55)
at test4.main(test4.java:17)
Caused by: org.hibernate.MappingException: Could not read mappings from resource: sp.hbm.xml
Please Help. This is my first post here.
Thanks in adv.