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 8986013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:27:03+00:00 2026-06-15T21:27:03+00:00

I am using a Existing DAO autowired in my ItemWriter to insert elements in

  • 0

I am using a Existing DAO autowired in my ItemWriter to insert elements in the database.

I have set the commit-interval = 5.

In my xml (read), i have put invalid data in the 5th element to test out the restart feature.

here is my ItemWriter:

@Component("transactionItemWriter")
public class TransactionInteracItemWriter implements   ItemStreamWriter<TransactionConciliationInterac> {
    private static final Logger log = Logger.getLogger(TransactionInteracItemWriter.class);
    @Autowired
    private ConciliationContext conciliationContext;
    @Autowired
    private ServiceTransactionConciliationInterac paiementService;
    private int transactionCount;

    /**
     * @see ItemWriter#write(java.util.List)
     */
    public void write(List<? extends TransactionConciliationInterac> data) throws Exception {

    int index = ++transactionCount - 1;


    while (index < data.size()) {
        TransactionConciliationInterac trx = data.get(index);
        paiementService.insertAndReturnKey(trx,conciliationContext.getIdSommaire().toString());
    index = ++transactionCount - 1;
    }
}

the paiementService is a Spring bean using JDBCTemplate to insert data in the DB.

my config :

        <batch:step id="traitementXmlIemtTransactionStep">
        <batch:tasklet transaction-manager="transactionManager" start-limit="10">
            <batch:chunk reader="IemtXmlTransactionReader" processor="IemtXmlTransactionConvertProcessor" writer="transactionItemWriter" commit-interval="5"/>
            <batch:transaction-attributes isolation="DEFAULT" propagation="REQUIRED"/>
            <batch:listeners>
                <batch:listener ref="transactionStepListener" />
            </batch:listeners>

        </batch:tasklet>
    </batch:step>

Now, when i run this, i see that i get an exception (DataIntegrityEx) :

<Rollback for RuntimeException: org.springframework.dao.DataIntegrityViolationException:   PreparedStatementCallback; SQL []; Data truncation: Data too long for column  'TRANSACTIONTYPE' at row 1; nested exception is com.mysql.jdbc.MysqlDataTruncation: Data  truncation: Data too long for column 'TRANSACTIONTYPE' at row 1>
2012-12-11 09:50:28,949 DEBUG [org.springframework.batch.repeat.support.RepeatTemplate]  - <Handling exception: org.springframework.dao.DataIntegrityViolationException, caused by:  org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [];  Data truncation: Data too long for column 'TRANSACTIONTYPE' at row 1; nested exception is  com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'TRANSACTIONTYPE' at row 1>
2012-12-11 09:50:28,949 DEBUG [org.springframework.batch.repeat.support.RepeatTemplate] - <Handling fatal exception explicitly (rethrowing first of 1): org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL []; Data truncation: Data too long for column 'TRANSACTIONTYPE' at row 1; nested exception is com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'TRANSACTIONTYPE' at row 1>
2012-12-11 09:50:28,950 ERROR [org.springframework.batch.core.step.AbstractStep] -    <Encountered an error executing the step>
org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL []; Data truncation: Data too long for column 'TRANSACTIONTYPE' at row 1; nested exception is com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'TRANSACTIONTYPE' at row 1
at     org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:101)

The step status look like this :

<Step execution complete: StepExecution: id=3, version=2, name=traitementXmlIemtTransactionStep, status=FAILED, exitStatus=FAILED, readCount=5, filterCount=0, writeCount=0 readSkipCount=0, writeSkipCount=0, processSkipCount=0, commitCount=0, rollbackCount=1>

This look ok, i can see i have read 5 elements, 0 were written and 1 rollback occurred.

BUT when i look in the Database, i can see that the first 4 elements were committed!!!!

I need help to find what i am doing wrong!

Regards

  • 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-06-15T21:27:05+00:00Added an answer on June 15, 2026 at 9:27 pm

    Finally found my issue!!! I was using MySql and by default, it uses MyIsam engine which does not support transactions.

    Changed it to innoDB and now everything works great.

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

Sidebar

Related Questions

We're using Grails but with an existing model layer and DAO layer. We have
Set up: New MVC 3 project, using existing database. Created an EF file (edmx),
I am using ZK to try to call Spring Manager/DAO from the existing spring
We're currently using a PostgreSQL database and OrmLite. We now have a use case
I currently am using existing code that has Sql.Append(UPDATE Store SET + LogoAlign=' +
I have a problem testing a logon method using existing AccountController (made by MVC)...
I have a large set of XML files of a propriatary schema -the XML
I'm using Websphere 7 . Using existing WSDL, I've created WS client using wsimport
Is there any way that we can mock certain methods using existing objects ?
Im using an existing widget from the jquery-ui labs call selectmenu. It has callback

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.