-->
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.  [ 1 post ] 
Author Message
 Post subject: Please HELP I am stucking with this problem!!!!!!!!
PostPosted: Fri Oct 19, 2007 1:32 am 
Newbie

Joined: Fri Oct 19, 2007 1:28 am
Posts: 1
Dear all

My Problem in brief that i want to call stored function from hibernate

i read the old posts in this forum but it did not help me in my problem

i want to call stored function that return some part of the class

attributes from the function call and the others to be set in java

all posts i found return the hall class which did not need

i just want to return part of the class only

in other words Is it required that stored procedure must return all the column in the resultset of the mapped class. i was trying to fetch only subset of column but i got invalid column name

here is the code

------------------------------
1) my hbm.xml file
-----------------------------
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="test.pojos.ObjectError" table="VALIDATIONERROR">

<id name="sammelNR" type="string">
<column name="SAMMEL_NR" />
<generator class="sequence"/>
</id>



<property name="rpStatus" column="RP_STATUS" generated="insert" />






</class>




<sql-query name="GETBOOLEANVALUES" callable="true">
<return entity-name="test.pojos.ObjectError">

<return-property name="sammelNR" column="SAMMEL_NR"/>



</return>

{ ? = call GETSAMMELNR() }
</sql-query>




<database-object>
<create>

CREATE OR REPLACE FUNCTION GETSAMMELNR RETURN SYS_REFCURSOR AS MY_CURSOR SYS_REFCURSOR;

BEGIN

OPEN MY_CURSOR FOR SELECT SAMMEL_NR FROM SCOTT.srp_rechnungen;


RETURN MY_CURSOR ;

END;
</create>
<drop>drop Function GETSAMMELNR</drop>

</database-object>


</hibernate-mapping>

---------------------------------------------------
2 ) POJO class
--------------------------------------------------



package test.pojos;

public class ObjectError {


private String sammelNR;

private String rpStatus;


public String getSammelNR() {

return sammelNR;
}


public void setSammelNR(String pSammelNR) {

sammelNR = pSammelNR;
}



public String getRpStatus() {

return rpStatus;
}



public void setRpStatus(String pRpStatus) {

rpStatus = pRpStatus;
}



}
---------------------------------------------------------------
3) the Exception
---------------------------------------------------------------

could not execute query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2148)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:111)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1674)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:147)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:164)
at test.main.MainClass.main(MainClass.java:56)
Caused by: java.sql.SQLException: Invalid column name
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:227)
at oracle.jdbc.driver.OracleStatement.get_column_index(OracleStatement.java:3047)
at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:1861)
at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1559)
at org.hibernate.type.StringType.get(StringType.java:18)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:113)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:102)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:1899)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1372)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1300)
at org.hibernate.loader.Loader.getRow(Loader.java:1197)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:569)
at org.hibernate.loader.Loader.doQuery(Loader.java:689)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
... 7 more






thanks in advance


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

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.