Re: How to call Oracle function which retrun Oracle record type?

136 views
Skip to first unread message

Guy Rouillier

unread,
Sep 7, 2012, 4:06:45 PM9/7/12
to mybati...@googlegroups.com
Can you show us an example of how you would do this with straight Java
and JDBC, without MyBatis? I found the following article using Google:
http://betteratoracle.com/posts/31-passing-record-types-between-oracle-and-java.
Based on the fact that you need to use Oracle-specific Java classes -
oracle.sql instead of java.sql - my guess would be that this cannot be
done with MyBatis.

On 9/6/2012 1:08 AM, Tural Muradbeyli wrote:
> I have record type in package specification:
>
> | TYPEPayment_Capabilities IS RECORD( pp_partial_payment NUMBER(1)
> DEFAULT0, co_advance_payment NUMBER(1) DEFAULT0, dp_deposit_payment
> NUMBER(1) DEFAULT0, dr_deposit_repay NUMBER(1) DEFAULT0,
> wp_wallet_payment NUMBER(1) DEFAULT0, wr_wallet_repay NUMBER(1)
> DEFAULT0, ss_prepaid_payment NUMBER(1) DEFAULT0);
>
>
> |and function which returns this type. I use MyBatis integration with
> Spring. How to call (using MyBatis XML Mapper) this function and map
> result to POJO object?
>


--
Guy Rouillier

Dridi Boukelmoune

unread,
Sep 10, 2012, 5:13:35 AM9/10/12
to mybati...@googlegroups.com
Hi,

Don't forget type handlers for specific API.
http://www.mybatis.org/core/configuration.html#typeHandlers

Dridi
http://www.zenika.com
--
Dridi Boukelmoune
Développeur/Formateur

GSM : +33 (0)6 17 91 14 23

Tural Muradbeyli

unread,
Oct 16, 2012, 3:31:00 PM10/16/12
to mybati...@googlegroups.com
<select id="identifyPaymentCapabilities" parameterType="PaymentCapabilities" statementType="CALLABLE">
    DECLARE
        v_payment_capabilities APS.Payment_Capabilities;
    BEGIN
        v_payment_capabilities := APS.get_payment_capabilities(#{customerId, javaType=Integer, jdbcType=NUMERIC, mode=IN});

        #{partialPaymentPP, javaType=Integer, jdbcType=NUMERIC, mode=OUT} := v_payment_capabilities.pp_partial_payment;
        #{advancePaymentCO, javaType=Integer, jdbcType=NUMERIC, mode=OUT} := v_payment_capabilities.co_advance_payment;
        #{depositPaymentDP, javaType=Integer, jdbcType=NUMERIC, mode=OUT} := v_payment_capabilities.dp_deposit_payment;
        #{depositRepayDR,   javaType=Integer, jdbcType=NUMERIC, mode=OUT} := v_payment_capabilities.dr_deposit_repay;
        #{walletPaymentWP,  javaType=Integer, jdbcType=NUMERIC, mode=OUT} := v_payment_capabilities.wp_wallet_payment;
        #{walletRepayWR,    javaType=Integer, jdbcType=NUMERIC, mode=OUT} := v_payment_capabilities.wr_wallet_repay;
        #{prepaidPaymentSS, javaType=Integer, jdbcType=NUMERIC, mode=OUT} := v_payment_capabilities.ss_prepaid_payment;
    END;
</select>

AntPort

unread,
Oct 17, 2012, 4:31:49 AM10/17/12
to mybati...@googlegroups.com
Please check this thread https://groups.google.com/forum/?fromgroups=#!topic/mybatis-user/ajPXb5UgIKc.
You can combine solution from the thread with the article in Guy's post...

(Notice: passing STRUCT parameters to CallableStatement might not work with ojdbc14 Oracle driver, use ojdbc6 instead...)
Reply all
Reply to author
Forward
0 new messages