Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Object Views

Object Views

From: Jens Baumeister <invalid_at_spam.no>
Date: Fri, 11 May 2001 18:22:59 +0200
Message-ID: <9dh3jh$r55$1@news.netcologne.de>

Hi,

I'm using Oracle 8i on Linux and I want to map table data into object views for easier JDBC access (mapping Oracle objects right into Java objects). I followed Oracle directions (mirrored e.g. on http://www-rohan.sdsu.edu/doc/oracle/server803/A54643_01/ch_objvw.htm ), but it doesn't work right.

This is my table:

 create table users (
   pk_id NUMBER,

    username VARCHAR2(20) NOT NULL,
    password VARCHAR2(20) NOT NULL,
    lastName VARCHAR2(50),

    firstname VARCHAR2(50),
    email VARCHAR2(100) NOT NULL
);

This is the corrseponding object:

create type user_obj as object (

   userID NUMBER,

    userName VARCHAR2(20),
    password VARCHAR2(20),
    lastName VARCHAR2(50),

    firstName VARCHAR2(50),
    email VARCHAR2(100)
);

and that's the object view:

create or replace view user_view of user_obj  with object OID (userid) as
 select pk_id,

 username,
 password,
 lastname,

 firstname,
 email
 from users;

When I do a select * on the object view, I get the data just as if it were a normal view, i.e there's no object that wraps them, just data columns.

The same happens when I access the view from JDBC using rs.getObject(1) - I don't get the complete thing in an Oracle object of type user_obj, instead I get just the first column (userid) as an integer and I can access the othercolumns with getObject(2) etc.

How do I map the table data into an object view that gives me a single object of type user_obj for each row?

Thanks for any help.

Jens Baumeister Received on Fri May 11 2001 - 11:22:59 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US