Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get oracle collection ( table / record ) into java

 
bksella sella
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the below package in Oracle

CREATE OR REPLACE PACKAGE CUSTOMER_MASTER
AS
TYPE CITY_REC IS RECORD (
CITY_ID NUMBER,
CITY_NNAME VARCHAR2(2000)
);

TYPE TY_CITY_TBL IS TABLE OF CITY_REC;
END CUSTOMER_MASTER;

...and have a function which returns a collection
of CITY_REC of type TY_CITY_TBL. Is it possible to
get this collection into Java by calling the
function ?

thanks
bkSella.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes and No. Not directly. You have to find a tool. You can use Hibernate, but the OUT parameter has to be the first paramter. There is a tool called JPublisher, which will create Java Objects based on Oracle Types. (Personally, I do not recommend using JPublisher, because you will want to create nicer DOs rather than use the classes that JPublisher creates directly).

But I am sure other tools, like some JDO and other ORM products that will allow you to map to these Oracle types.

Mark
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sella,
As far as I know, record-types aren't supported. Use an object type instead -- and it needs to be a database type, not a type defined in a package, as in:

Don't remember the exact syntax. See the Oracle documentation for exact syntax.

Then in JDBC you can use a combination of STRUCT and ARRAY to retrieve the information. I believe you will find some examples on the OTN Web site:

http://www.oracle.com/technology

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