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