-->
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: stored procedure returning a non persisted entity
PostPosted: Wed Oct 18, 2006 2:45 pm 
Newbie

Joined: Mon Nov 14, 2005 5:57 pm
Posts: 11
I would like to call a stored procedure from hibernate and store the results in a non-persisted entity. I came across one posting from March 2006 that mentioned that this can be accomplished once Hibernate 3.2 is releases using a result transformer.
Is this true? If so, are there any changes that need to be made to the hibernate-mapping file (an example of my file is below) for this to work? (The reason I ask is because the same posting mentions not using an alias)

an example would be extremely helpful.

StoredProcedures.hbm.xml file;
Code:
<hibernate-mapping>
<sql-query name="test_sp" callable="true">
   <return alias="StoredProcedureOutputDTO" class="com.ecm.web.dto.StoredProcedureOutputDTO">
           <return-property name="toEmail" column="TOEMAIL"/>
   </return>
   {? = call TEST_STORED_PROC(myinput) }
</sql-query>
</hibernate-mapping>


stored procedure;
Code:
CREATE OR REPLACE PROCEDURE TEST_SP (
   myoutput OUT SYS_REFCURSOR,
   myinput IN VARCHAR
)
AS
BEGIN
OPEN myoutput FOR 
SELECT TOEMAIL FROM MESSAGE WHERE ID = myinput;
END;


java code;
Code:
return super.getHibernateSession().getNamedQuery("test_sp").setResultTransformer(new AliasToBeanResultTransformer(StoredProcedureOutputDTO.class)).setParameter("myinput", "1").list();


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.