Jitu Ji

Greenhorn
+ Follow
since Oct 10, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jitu Ji

Hi,

I am using Hibernates getNamedQuery() API to call a stored proc and I need to pass an array to Oracle stored proc.
How can I set that array type parameter using setParameter().

Please suggest.

Thanks










Thanks
Jitender
my mapping file is in the same folder where my Java files are.
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.
Hi,

I have a stored proc as given following:



tmp_usersreport is a global temp table defined in ORACLE DB.

My Hibernate mapping is called sp.hbm.xml:




My return DTO is:






Java Code to call stored proc:



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.