Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6022939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:55:54+00:00 2026-05-23T03:55:54+00:00

I have looked for the answer to this high and low but cannot get

  • 0

I have looked for the answer to this high and low but cannot get the answer.

Basically I have an object I am writing to my db using iBatis. This works fine with primitive types like strings, int’s etc but one of the attributes of my object is an array of other objects. I would like to be able to persist this and then later call the ‘selectById’ statement and retrieve the full object including the array.

Here is the code I have so far:

Mapper.xml

  <insert id="insertTrade" parameterClass="TradeObject">
insert into TESTTABLE (
  ORDERID,
  MAXPX,
  COMMISSION,
  ACCOUNTGRP )
values (
  #orderID#, #maxPx#, #commission#, #accountGrp#
)

accountGrp is my array but its currently throwing an error. The statement works fine without this field.

The java is like so:

  public static void insertTrade (Trade obj) throws SQLException {
  logger.debug("inserting trade. Order Id: " + obj.toString());
sqlMapper.insert("insertTrade", obj);

}

Thanks for any help in advance!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:55:54+00:00Added an answer on May 23, 2026 at 3:55 am

    I’ve done with Mybatis3, should be similar in the old iBatis stuff. To get the JDBC stuff, read this thread. It’s a huge thread, but it is there. Look for “ArrayDescriptor”.

    Basicually, you need to write a TypeHandler. In the TypeHandler, call setArray. Should be something like this in mybatis 3.x. Your working with a List, just convert with the toArray method. This is an example, where the parameter is a String[].

    import oracle.sql.ARRAY;
    import oracle.sql.ArrayDescriptor;   
    .....
    public void setParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException
    {
     //null check?
    
       ArrayDescriptor desc = ArrayDescriptor.createDescriptor("STRARRAY ", ps.getConnection());
       ARRAY oracleArray = new ARRAY(desc, ps.getConnection(), parameter);
       ps.setArray(i, oracleArray);
    }
    

    and maybe something like this in ibatis,

    public void setParameter(ParameterSetter setter, Object parameter) throws SQLException
    {
        ArrayDescriptor desc = ArrayDescriptor.createDescriptor("STRARRAY", setter.getPreparedStatement().getConnection());
        ARRAY oracleArray = new ARRAY(desc, setter.getPreparedStatement().getConnection(), parameter);
        setter.setArray(oracleArray);
    }
    

    Make your you’ve built a type, like it says in that thread.

    i.e.

    CREATE OR REPLACE TYPE STRARRAY AS TABLE OF VARCHAR2 (255)
    

    Then in the SQL map, make sure to reference the type handler.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have looked everywhere for the answer to this question, but cannot find anything
I have looked all over but can't find an answer to this... Quite simply
I have googled on this topic and I have looked at every answer, but
This is no doubt a newbish question, but I have looked for an answer
I've looked high and low for an answer to this and I'm hoping someone
I have looked through the answers in this forum but cannot seem to find
I know this has been asked before but I have looked at every answer
I have looked into this and cannot find a suitable answer. I want to
I have looked for the answer to this on Google and stackoverflow, but unfortunately
I have looked around on the Internet trying to answer this question. It seems

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.