I am new to Hibernate and am trying to execute a database function/stored procedure and am getting a HibernateSystemException (Named query not known). From the postings that I have read, it seems that the steps are all completed but this is definitely not working.
I'm running it on an Oracle 9i with JDK 6.
How I've configured hibernate and Spring:
1. Set up a META-INF/hbm.xml file:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<sql-query name="getdetails_FN"
callable="true">
<return class="com.mycompany.Company" />
{ call get_company_details_FN (?, :companyId) }
</sql-query>
</hibernate-mapping>
Code:
public String getCompanyDetails(String companyId) {
Company company = null;
List companyDetailsList;
try{
companyDetailsList = sessionFactory.getCurrentSession().getNamedQuery("getdetails_FN").setParameter("companyId", companyId).list();
company = systemTraceNumberList.get(0);
}
catch (Exception e){
}
return company;
}
Now, I'm not sure how Hibernate/Spring reads this hbm.xml file so that the session has a named query, but I am wondering whether that is the issue. Has anyone been able to get this to work?
Thank you.