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

  • SEARCH
  • Home
  • 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 6142405
In Process

The Archive Base Latest Questions

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

I have a table that generates with an auto-generated column but I am unable

  • 0

I have a table that generates with an auto-generated column but I am unable to retrieve the ID using MyBatis. I have proven through tests that the SQL is working and that the rows are being inserted but I cannot get the ID generated.

The XML configuration is:

<insert id="insertRequestTrackingRow" parameterType="map">
    INSERT INTO XML_LOG_T (REQ_SRC_SYS_CDE, REQ_USR_ID, REQ_XML_DOC, ROW_CRT_DTM, ROW_UPDT_DTM)
    VALUES (#{sourceSystemCode}, #{userID}, #{message}, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
</insert>

On the XML_LOG_T is a column, REQ_ID, that is auto-generated. My mapper interface is:

public interface UdbDataMapper {
    int insertRequestTrackingRow(
            @Param("message") String message,
            @Param("sourceSystemCode") String sourceSystemCode,
            @Param("userID") String userID);
}

What is returned is always 1, which I believe is the number of records inserted. I’m sure I am missing something obvious but cannot see the wood for the trees.

  • 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-23T18:22:55+00:00Added an answer on May 23, 2026 at 6:22 pm

    Here’s a pretty good explanation of how to do this.

    Basically you have to use the useGeneratedKeys=”true” and keyproperty=”keyfield” attributes in your XML configuration for the INSERT statement. The returned key field value is then inserted into your parameter object and can be retrieved from there. Something like the following code sample should work:

    SqlSessionFactory sqlMapper = new SqlSessionFactoryBuilder().build(Resources.getResourceAsReader("sqlConfig.xml"));
    SqlSession sess = sqlMapper.openSession();
    try {
       Map<String,String> paramObj = new HashMap<String,String>();
       paramObj.put("param1", "value");
       int result = sess.insert("insertRequestTrackingRow", paramObj);
       System.out.println("REQ_ID: " + paramObj.get("REQ_ID"));
    }
    finally {
       sess.close();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the table class that auto-generates a table for me from an array
I'm working on databases that have moving tables auto-generated by some obscure tools. By
I have a script that takes a table name and generates a control file
I have a table that's generated by a normal PHP loop. What I want
I have an html table containing values that are being generated from javascript. How
I have an applicaton that contains some tables that are auto-generated from Grails domain
I'm accessing a data context object that is auto-generated by using LINQ to SQL.
I'm trying to use auto-generated forms in symfony, but I have troubles finding good
I have some PHP code that generates dynamic tables of data on the fly.
I have long tables generated by datagrid control that go beyond the page width.

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.