I am trying to use Stored Procedures(MS SQL Server 2000 + iNet Opta Drviers) with Hibernate 3.0.
When Hibernate is trying to get data from the stored procedure.. it is trying to get it by the colums ALIAS, the call is failing with the following exception. I trying to list the result of the query..
Query namedQuery = s.getNamedQuery("getaccountid");
List list = namedQuery.list();
Can some one tell me how to avaoid colums ALIAS getting used for Stored Procedure or how to fix this issue.
FYI: here is the stack and the mapping...
---------------EXCEPTION STACK----------------
21:06:07,501 ERROR JDBCExceptionReporter - [TDS Driver]Column 'SYNCID0_' not found.
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:59)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:1518)
at org.hibernate.loader.Loader.list(Loader.java:1498)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:103)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1340)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:151)
at com.patientkeeper.ge.hibernate.GeDatabase.main(GeDatabase.java:125)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Caused by: java.sql.SQLException: [TDS Driver]Column 'SYNCID0_' not found.
at com.inet.tds.n.findColumn(Unknown Source)
at com.inet.tds.n.getLong(Unknown Source)
at org.hibernate.type.LongType.get(LongType.java:26)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:77)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:68)
at org.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:691)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:280)
at org.hibernate.loader.Loader.doQuery(Loader.java:387)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:206)
at org.hibernate.loader.Loader.doList(Loader.java:1515)
---------------EXCEPTION STACK END----------------
-------------------------MAPPING--------------------
My Mapping is:-
<?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 package="com.patientkeeper.ge.data" default-access="field">
<class name="Account">
<id name="syncid" type="java.lang.Long" column="SYNCID">
<generator class="increment"/>
</id>
<property name="syncversion" type="java.lang.Long" not-null="false" column="SYNCVERSION"/>
<sql-insert > </sql-insert>
<sql-update> </sql-update>
<sql-delete> </sql-delete>
</class>
<sql-query name="getaccountid" callable="true">
<return alias="" class="Account">
<return-property name="syncid" column="SYNCID"/>
<return-property name="syncversion" column="SYNCVERSION"/>
</return>
{ call getaccountid }
</sql-query>
</hibernate-mapping>
|