Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Complex data object returned from oracle

 
Din Carl
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

It is my first time posting question here, and if anything not clear please let me know. I am having trouble with complex object returned from stored procedure. I have something like this:


Then I do this is java:

My issue is when array.getArray() (Point A) is called, then it calls A.readSQL() (Point B) first so that all data is set and saved somewhere. Then at Point C, it calls A.readSQL() again but at this time there no more data to read as it has been read, and the result is I get B object with null values, no exception occurs. I been struggling for 2 days and couldn't figure it out. Everything parses out correctly if I use B as param instead of BLIST.

Please help. Thanks.

Carl
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Din Carl! Can you please UseCodeTags next time? It makes your code easier to read.
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carl,
I suggest using Oracle's JDBC thin driver which maps database table types, like your BLIST type, to java.sql.Array and object types, like your types A and B, to java.sql.Struct.
Also, I personally prefer using a PL/SQL stored function, rather than a stored procedure with an OUT parameter.

Good Luck,
Avi.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic