Hi,
I am facing the problem while executing the calling of funtion through named query.
My
java bean class file like this
package org.com.test;
public class Contact {
private
String firstName;
private String lastName;
private String email;
private long contact_id;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public long getContact_id() {
return contact_id;
}
public void setContact_id(long contact_id) {
this.contact_id = contact_id;
}
}
and hbm file is like this
<?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="org.com.test.Contact" table="TEST_CONTACT">
<id name="contact_id" type="long" column="CONTACT_ID">
<generator class="assigned" />
</id>
<property name="firstName">
<column name="FIRST_NAME" />
</property>
<property name="lastName">
<column name="LAST_NAME" />
</property>
<property name="email">
<column name="EMAIL_ID" />
</property>
</class>
<query name="HQLtest"><![CDATA[ select contact.firstName from Contact contact ]]>
</query>
<sql-query name="HQLtestFunction" callable="true">
<return class="org.com.test.Contact" alias="contact">
<return-property name="contact.firstName" column="First_name" />
</return>
{ ?=call Fn_ViewContact() }
</sql-query>
</hibernate-mapping>
i am using the oracle database my function is as follows:
CREATE OR REPLACE FUNCTION Fn_ViewContact
RETURN SYS_REFCURSOR
AS
st_cursor SYS_REFCURSOR;
BEGIN
OPEN st_cursor FOR
SELECT First_name from test_contact ;
RETURN st_cursor;
END;
i am calling this named query as in java like this
Query queryFunc = session.getNamedQuery("HQLtestFunction");
List FunctionResult = queryFunc.list();
displayObjectList(FunctionResult);
My problem is that when i am ruuning the queryFun.list();
I am getting the error
Hibernate: { ?=call Fn_ViewContact() }
43281 [main] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 17006, SQLState: null
43281 [main] ERROR org.hibernate.util.JDBCExceptionReporter - Invalid column name
could not execute query
please help me regarding this urgently.
Many many thanks in advance.
Best Regards
Garima