diff options
author | 2018-02-17 23:53:48 +0300 | |
---|---|---|
committer | 2018-02-22 13:15:59 +0300 | |
commit | 8799068b593b9dd40b569a520c32b7e7dd541783 (patch) | |
tree | 4688be0d41490453370135c5e009aac511f04cd9 /juick-server-jdbc/src/main/java/com/juick/service/PushQueriesServiceImpl.java | |
parent | 2b267c04f4c77c6fae5c591e45d987b3f4b3bab3 (diff) |
run tests on h2 database
Diffstat (limited to 'juick-server-jdbc/src/main/java/com/juick/service/PushQueriesServiceImpl.java')
-rw-r--r-- | juick-server-jdbc/src/main/java/com/juick/service/PushQueriesServiceImpl.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/juick-server-jdbc/src/main/java/com/juick/service/PushQueriesServiceImpl.java b/juick-server-jdbc/src/main/java/com/juick/service/PushQueriesServiceImpl.java index 878d10d5..7f97956c 100644 --- a/juick-server-jdbc/src/main/java/com/juick/service/PushQueriesServiceImpl.java +++ b/juick-server-jdbc/src/main/java/com/juick/service/PushQueriesServiceImpl.java @@ -18,6 +18,7 @@ package com.juick.service; import org.apache.commons.collections4.CollectionUtils; +import org.springframework.dao.DuplicateKeyException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; import org.springframework.stereotype.Repository; @@ -132,7 +133,11 @@ public class PushQueriesServiceImpl extends BaseJdbcService implements PushQueri @Transactional @Override public boolean addAPNSToken(Integer uid, String token) { - return getJdbcTemplate().update("INSERT IGNORE INTO ios(user_id,token) VALUES (?, ?)", - uid, token) > 0; + try { + return getJdbcTemplate().update("INSERT INTO ios(user_id,token) VALUES (?, ?)", + uid, token) > 0; + } catch (DuplicateKeyException e) { + return true; + } } } |