From 4d8842d3254886b1925015e0cd24005dd927dd2a Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 10 Apr 2018 14:21:20 +0300 Subject: server: add minimal telegram test --- .../src/main/java/com/juick/service/TelegramServiceImpl.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'juick-server-jdbc/src/main') diff --git a/juick-server-jdbc/src/main/java/com/juick/service/TelegramServiceImpl.java b/juick-server-jdbc/src/main/java/com/juick/service/TelegramServiceImpl.java index 14cdfc8f..4e37bfac 100644 --- a/juick-server-jdbc/src/main/java/com/juick/service/TelegramServiceImpl.java +++ b/juick-server-jdbc/src/main/java/com/juick/service/TelegramServiceImpl.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.stereotype.Repository; import org.springframework.transaction.annotation.Transactional; @@ -36,7 +37,11 @@ public class TelegramServiceImpl extends BaseJdbcService implements TelegramServ @Transactional @Override public boolean addChat(final Long id) { - return getJdbcTemplate().update("INSERT IGNORE INTO telegram_chats(chat_id) VALUES(?)", id) > 0; + try { + return getJdbcTemplate().update("INSERT INTO telegram_chats(chat_id) VALUES(?)", id) > 0; + } catch (DuplicateKeyException e) { + return true; + } } @Transactional -- cgit v1.2.3