From cda8b704fd56ff6596690faeb793f23078f1b2d4 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 18 Dec 2022 11:26:29 +0300 Subject: `addGCMToken` fix --- src/main/java/com/juick/service/PushQueriesServiceImpl.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/main/java/com/juick/service') diff --git a/src/main/java/com/juick/service/PushQueriesServiceImpl.java b/src/main/java/com/juick/service/PushQueriesServiceImpl.java index 0dfa59df..0b83465a 100644 --- a/src/main/java/com/juick/service/PushQueriesServiceImpl.java +++ b/src/main/java/com/juick/service/PushQueriesServiceImpl.java @@ -57,8 +57,12 @@ public class PushQueriesServiceImpl extends BaseJdbcService implements PushQueri @Transactional @Override public boolean addGCMToken(Integer uid, String token) { - return getJdbcTemplate().update("INSERT IGNORE INTO android(user_id,regid) VALUES (?, ?)", - uid, token) > 0; + try { + return getJdbcTemplate().update("INSERT INTO android(user_id,regid) VALUES (?, ?)", + uid, token) > 0; + } catch (DataIntegrityViolationException e) { + return false; + } } @Transactional -- cgit v1.2.3