From 2236eee046e3ce304a3adcd9305ae6d6d2555003 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 13 Jun 2018 17:46:13 +0300 Subject: h2db: disable mysql mode --- .../main/java/com/juick/service/PMQueriesServiceImpl.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'juick-server-jdbc/src/main/java/com/juick/service') diff --git a/juick-server-jdbc/src/main/java/com/juick/service/PMQueriesServiceImpl.java b/juick-server-jdbc/src/main/java/com/juick/service/PMQueriesServiceImpl.java index 67d7b386..b68e0236 100644 --- a/juick-server-jdbc/src/main/java/com/juick/service/PMQueriesServiceImpl.java +++ b/juick-server-jdbc/src/main/java/com/juick/service/PMQueriesServiceImpl.java @@ -18,6 +18,7 @@ package com.juick.service; import com.juick.User; +import org.springframework.dao.DuplicateKeyException; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; import org.springframework.jdbc.core.namedparam.SqlParameterSource; import org.springframework.stereotype.Repository; @@ -39,10 +40,13 @@ public class PMQueriesServiceImpl extends BaseJdbcService implements PMQueriesSe uidFrom, uid_to, body) > 0; if (ret) { - getJdbcTemplate().update( - "INSERT INTO pm_streams(user_id, user_id_to, lastmessage, unread) VALUES (?, ?, NOW(), 1) " - + "ON DUPLICATE KEY UPDATE lastmessage = CURRENT_TIMESTAMP(), unread = unread + 1", - uidFrom, uid_to); + try { + getJdbcTemplate().update( + "INSERT INTO pm_streams(user_id, user_id_to, lastmessage, unread) VALUES (?, ?, NOW(), 1)", + uidFrom, uid_to); + } catch (DuplicateKeyException e) { + // ignore + } } return ret; } -- cgit v1.2.3