• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Exception while calling stored proc from hibernate. URGENT Help

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is very difficult to read. You can edit your post to include them by using the button.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where is your mapping file located?
 
Jitu Ji
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my mapping file is in the same folder where my Java files are.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then you need to add the package directories here

<mapping resource="sp.hbm.xml"/>

Because with that above, it will try to find the xml file in the root of the classpath, where it does not exist.

Mark
 
If you two don't stop this rough-housing somebody is going to end up crying. Sit down and read this tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic