-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: problem in executing stored procedure
PostPosted: Fri Feb 17, 2006 5:10 pm 
Newbie

Joined: Thu Jan 26, 2006 1:10 pm
Posts: 6
Hi,

I would appreciate all the help in regards to an issue I have When trying to execute a stored procedure.

Here is the details:

Hibernate Version: 3.0
JDBC Driver: com.sybase.jdbc3.jdbc.SybDataSource

Name of Database: Sybase Adaptive Server Enterprise v12.5.0.3

Mapping Documents:

<?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 package="com.un.itsd.mgt.hibernate.mapping">

<class name="Slde" table="SLDE">
<id name="id" column="prm_key" type="java.lang.Long">
<generator class="native"/>
</id>
<property name="cnvrtAmt" column="cnvrt_amt" type="java.lang.Double" />
<property name="orguIdCode" column="orgu_id_code" type="java.lang.String" />
<property name="objtIdCode" column="objt_id_code" type="java.lang.String" />
<property name="objcIdCode" column="objc_id_code" type="java.lang.String" />
<property name="fundIdCode" column="fund_id_code" type="java.lang.String" />
</class>
<sql-query name="SldeClassification" callable="true">
<return alias="s" class="Slde">
<return-property name="fundIdCode" column="f_fund_id_code"/>
<return-property name="orguIdCode" column="f_orgu_id_code"/>
</return>
{?= call classification() }
</sql-query>
</hibernate-mapping>

The stored procedure

create proc classification
as
select fund_id_code, orgu_id_code from SLDE where objc_id_code='373'

The code

session = HibernateSessionFactory.currentSession();
Transaction tx = session.beginTransaction();
List myList = session.getNamedQuery("SldeClassification").list();
tx.commit();
HibernateSessionFactory.closeSession();

The stack trace

Exception in thread "main" 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:1596)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:112)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1414)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:153)
at test.sldeTest.list(sldeTest.java:22)
at test.sldeTest.main(sldeTest.java:16)
Caused by: java.sql.SQLException: S0022: Invalid column name 'prm1_0_'.
at com.sybase.jdbc3.jdbc.ErrorMessage.raiseError(Unknown Source)
at com.sybase.jdbc3.tds.TdsResultSet.findColumnByLabel(Unknown Source)
at com.sybase.jdbc3.jdbc.SybResultSet.findColumn(Unknown Source)
at com.sybase.jdbc3.jdbc.SybResultSet.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:759)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:292)
at org.hibernate.loader.Loader.doQuery(Loader.java:412)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
... 6 more


Can you please help me to figure out why I am getting "java.sql.SQLException: S0022: Invalid column name 'prm1_0_'"?

Thanks for all the help.

Regards,

Sam


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 18, 2006 9:26 pm 
Newbie

Joined: Thu Jan 26, 2006 1:10 pm
Posts: 6
Can any body help me?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 10:46 am 
Newbie

Joined: Thu Mar 15, 2007 10:11 am
Posts: 19
Location: Dallas
your output in the stored procedure should contain all the fields of the returned object. Don't forget to rate.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 05, 2007 10:17 am 
Newbie

Joined: Sun Jul 29, 2007 5:32 pm
Posts: 1
Is there any way to work around the fact that Hibernate requires the stored procedure to contain all the fields of the returned object?
I would like to partially initialize a class with results of a stored procedure and cannot find a way to do that.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 27, 2008 7:26 am 
Newbie

Joined: Tue Feb 26, 2008 10:49 am
Posts: 1
Solution:
I added the @Transient annotation to the Getter-methods of attributes that I cannot map to the stored procedure. Hibernate (and in my case the EJB3 persistence layer) doesn't complain anymore now!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.