-->
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.  [ 2 posts ] 
Author Message
 Post subject: Oracle Stored Procedure with refcursor as OUT parameter
PostPosted: Thu Sep 21, 2006 9:23 am 
Newbie

Joined: Thu Sep 21, 2006 9:08 am
Posts: 1
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.2

Hi, I am trying to map an Oracle oracle stored proc with one out parameter which is a refcursor. Here is the header of the proc:

PROCEDURE get_bag_track_by_location_v2
(
p_location IN tracking_log.location%TYPE,
p_date IN varchar2,
p_loginname IN tagtrak_users.loginname%TYPE,
p_flight_id IN flight.flight_id%TYPE,
p_user_pref IN VARCHAR2,
p_cursor OUT SYS_REFCURSOR
);

Here are my annotations used in my entity class (param6 is the outparameter i mentioned):

@SqlResultSetMapping(name = "getBagTracksByLocationResultSetMapping", entities = {@EntityResult(entityClass = LogEntry.class, fields = {
@FieldResult(name = "arriveFlight", column = "p_arr_flight"),
@FieldResult(name = "departureFlight", column = "p_dep_flight"),
@FieldResult(name = "destination", column = "p_des"),
@FieldResult(name = "event", column = "p_st_ev_no"), @FieldResult(name = "from", column = "p_org"),
@FieldResult(name = "loader", column = "p_loader"),
@FieldResult(name = "passengerID", column = "p_pax_id"),
@FieldResult(name = "tagNumber", column = "p_bag_tag"), @FieldResult(name = "time", column = "p_time"),
@FieldResult(name = "uld", column = "p_group_no")})})

@NamedNativeQuery(name = "getBagTracksByLocationQuery",
query = "{call MWS_TRACKING.GET_BAG_TRACK_BY_LOCATION_V2(:param1, :param2, :param3, :param4, :param5, :param6)}",
resultSetMapping = "getBagTracksByLocationResultSetMapping",
hints = {@QueryHint(name = "org.hibernate.callable", value = "true")}

And finally, here is where I create the query:


Query query = entityManager.createNamedQuery("getBagTracksByLocationQuery");

query.setParameter("param1","MBZRH");
query.setParameter("param2","");
query.setParameter("param3","ZRH");
query.setParameter("param4",0);
query.setParameter("param5","A");
query.setParameter("param6",null);
List results = query.getResultList();

The problem I have is that no matter how I have tried, I get an Exception stating "invalid column index". Since support for stored procedures that contain OUT parameters is fairly recent, there seems to be few examples out there to follow, so any help would be greatly appreciated!

I know I could just change the stored procs to be functions but the DB is huge and would involve too much re-work.

Mike


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 22, 2006 9:52 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
as in the doc it has to be the first parameter.

if not then you have to provide a specialized dialect that overrides the getResultset method.

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.