Search code examples
javaoracle-databaseoracle-aq

How to cast AQMessage STRUCT object to UDT object


Trying to read a message with UDT payload from oracle AQ queue in java. I used jpub to create java classes for my Oraacle UDT/Object in the database (object called MESSAGE_TYP).

jpub output:

public class message_typ implements ORAData, ORADataFactory ...

Then deuque message and get STRUCT:

oracle.jdbc.aq.AQMessage msg = conn.dequeue(queueName, deqopt, "MESSAGE_TYP");
STRUCT st = msg.getSTRUCTPayload();

So How do I then get to my concrete message_typ object reference?


Solution

  • Figured it out. After call to msg.getSTRUCTPayload():

        message_typ typ;  // My UDT created with jpub
        ORADataFactory of = message_typ.getORADataFactory();
        ORAData od = of.create(st, 1);
        typ = (message_typ)od;