-->
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: Problem using Stored Procedure returning nested object!
PostPosted: Thu May 28, 2009 7:15 am 
Newbie

Joined: Thu May 28, 2009 6:36 am
Posts: 1
Our problem is that we want to use a stored procedure to collect and return
a more complex structure.
For example, it should be possible to return a list of orders
where each row in the list inlcudes a number of order rows.

We have tested this with an Oracle Stored Procedure
Code:
  PROCEDURE test
    (v_result OUT SYS_REFCURSOR)
  IS
    v_order_list  order_list := order_list();
    v_order_row_list order_row_list := order_row_list();
  BEGIN
   v_order_row_list.extend(1);
   v_order_row_list(1) := order_row_obj(4712,'text1');
   v_order_row_list.extend(1);
   v_order_row_list(2) := order_row_obj(4713,'text2');
   
   v_order_list.extend(1);
   v_order_list(1) := order_obj(4711,'text3',v_order_row_list);
 
    OPEN v_result FOR
    SELECT * FROM TABLE (v_order_list);
  END test;

ORDER_OBJ and ORDER_ROW_OBJ are defined like this:
Code:
CREATE OR REPLACE TYPE "ORDER_ROW_OBJ"
AS OBJECT (ORDER_ROW_ID NUMBER, ORDER_ITEM VARCHAR2(100))
/
CREATE OR REPLACE TYPE "ORDER_ROW_LIST"
AS TABLE OF "ORDER_ROW_OBJ"
/
CREATE OR REPLACE TYPE  "ORDER_OBJ"
AS OBJECT (ORDER_ID NUMBER, ORDER_TITLE VARCHAR2(100), ORDER_ROWS ORDER_ROW_LIST)
/
CREATE OR REPLACE TYPE "ORDER_LIST"
AS TABLE OF "ORDER_OBJ"
/

How can we retrieve this kind of data structure in a hibernate request?
We have tried this:
Code:
@Entity
@NamedNativeQuery (
                name = "Order.test",
                query = "{call test(?)}",
                resultClass = Order.class,
                hints = {
                        @QueryHint(name = "org.hibernate.callable", value = "true"), 
                        @QueryHint(name = "org.hibernate.readOnly", value = "true") 
                } 
)
public class Order {
        @Id
        @Column(name = "order_id")
        private Integer id;
       
        @Column(name = "order_title")
        private String title;

//Getters and Setters
}

The code above works, but how can we retrieve the order_rows?
Is it possible for hibernate to map this kind of structure?
Is there a recommended solution for this problem?

We are running JBoss 5.1 and Oracle 10g, Release 2, Enterprise Edition.


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.