aboutsummaryrefslogtreecommitdiff
path: root/juick-server-jdbc/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server-jdbc/src/main/java')
-rw-r--r--juick-server-jdbc/src/main/java/com/juick/service/PMQueriesServiceImpl.java12
1 files changed, 8 insertions, 4 deletions
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;
}