pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chris Dole <chris.dole@sas.com>
To: pgsql-jdbc@postgresql.org
Subject: MyBatis Batch Update Leads to PSQLException "Too many update results were returned"
Date: Tue, 27 Feb 2018 14:19:21 -0700 (MST)
Message-ID: <1519766361988-0.post@n3.nabble.com> (raw)

I have a fairly simple implementation of a batch update via the MyBatis
functionality.

Postgres version (via RDS on Amazon Web Services): 9.6.6
JDBC driver version: 9.4

The error manifests as follows:

DataIntegrityViolationException
Root cause: BatchUpdateException
getNextException: PSQLException - Too many update results were returned.

Has anyone else run into this? I have searched far and wide for an
explanation (including here) but have not found an answer yet.

I assume this error is coming up from the JDBC driver?

The curious thing is that the update seems to work (as in database
side-effects) but it still throws an exception afterward.

Here is a fragment of the MyBatis mapper XML file for the update. The
failure can happen for as few as two or three updates, and it can succeed
with hundreds.

    <update id="update" parameterType="java.util.List">
        <foreach collection="list" item="item" index="index" separator=";">
            UPDATE public.vid_event_timing SET mark_delete = 1 WHERE
            visitor_id=#{item.vid} AND timed_node_id=#{item.timedNodeId} AND
conditional_node_id= #{item.conditionalNodeId}
        </foreach>
    </update>

The MyBatis/Spring configuration includes this session factory bean, set to
ExecutorType.BATCH by default.

    @Bean
    public SqlSessionTemplate getSqlSessionTemplate()
    {
        SqlSessionFactory sessionFactory = null;
        try 
        {
            sessionFactory =
getMktPersistDesignSqlSessionFactoryBean().getObject();
           
sessionFactory.getConfiguration().setDefaultExecutorType(ExecutorType.BATCH);
        } 
        catch (Exception e) 
        {
            String message = PersistLogUtil.error(logger, "Failed to create
SqlSessionTemplate");
            throw new RuntimeException(message, e);
        }
        SqlSessionTemplate template = new
SqlSessionTemplate(sessionFactory);
        return template;
    }

Thanks for any help.




--
Sent from: http://www.postgresql-archive.org/PostgreSQL-jdbc-f2168246.html




view thread (6+ messages)  latest in thread

Message-ID: <1519766361988-0.post@n3.nabble.com>
Permalink:  ../1519766361988-0.post@n3.nabble.com/
Also on:    postgresql.org/message-id/1519766361988-0.post@n3.nabble.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: chris.dole@sas.com
  Subject: Re: MyBatis Batch Update Leads to PSQLException "Too many update results were returned"
  In-Reply-To: <1519766361988-0.post@n3.nabble.com>
  References: <1519766361988-0.post@n3.nabble.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox