Results 1 to 7 of 7

Thread: Object reference to number

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769

    Object reference to number

    Hi all,

    I am new to Java and need some assistance. I am using java stored procedures in Oracle and need to convert an object reference in java to a number so that I can pass it back to Oracle for later use. I remember in vb6 there was a function to do this and I was hoping that Java would also have a similar ability....

    Thanks

  2. #2
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Object reference to number

    I'm a bit confused on the "later use" part... what if the object no longer exists? As to passing Java objects to Oracle, you have to break it up into relevant PL/SQL data types. When your already in the stored Java code that's when you can pass Java objects around internally in the database.

    Please explain again what you are trying to accomplish.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769

    Question Re: Object reference to number

    Ok, I will try and give a better explanation....

    As of Oracle 817, Oracle made available a PL/SQL package for XML manipulation (dbms_xmldom). The implementation behind this PL/SQL package was done in Java. Now, using their PL/SQL package, you are able to create an XMLDocument object. This object is actually a java object, but a "pointer" is returned to the calling PL/SQL procedure for use in subsequent calls.
    Code:
    create or replace procedure mycustomproc as
    
       l_doc   dbms_xmldom.DOMDocument;
    
    begin
    
       l_doc := dbms_xmldom.newDOMDocument();
       dbms_xmldom.freeDocument(l_doc);
    
    end mycustomproc;
    The dbms_xmldom.DOMDocument type is defined by Oracle as
    Code:
    type DOMDocument is record(id raw(12));
    The l_doc variable is therefore a pointer to an instanciated java object. As seen in the example, this can be used in subsequent calls to the package.

    I want to create the same effect using my own custom java object. Problem is, I don't know how to get the raw id that refers to the object.... Any ideas?

  4. #4
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Object reference to number

    Try returning the hash code... internally the java maintains collection using hash code to retrieve instances... that is why you need to call freeDocument to remove the instance from the collection.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769

    Re: Object reference to number

    Thanks.. I am now using a private static hashtable to store references to the objects and am returning the hash code back to pl/sql. Doesn't seem like the most elegant solution to me, but it is working just fine for now. I am just hoping that there won't be issues with multiple threads using the library. Time will tell....

  6. #6
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Object reference to number

    You can use JMeter to simulate multiple users and plot performance.

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769

    Re: Object reference to number

    Hmm... looks promising... will investigate

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width