From c8103ad9478f928e366b784ef95e4d92068ab4ed Mon Sep 17 00:00:00 2001 From: Sanny Sanoff Date: Fri, 15 Jul 2016 21:33:25 +0300 Subject: additional nail into the coffin of duplicate sequence values for replies --- juick-core/src/main/java/com/juick/server/MessagesQueries.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'juick-core/src/main/java') diff --git a/juick-core/src/main/java/com/juick/server/MessagesQueries.java b/juick-core/src/main/java/com/juick/server/MessagesQueries.java index e6188a86..5659e79c 100644 --- a/juick-core/src/main/java/com/juick/server/MessagesQueries.java +++ b/juick-core/src/main/java/com/juick/server/MessagesQueries.java @@ -159,6 +159,9 @@ public class MessagesQueries { return sql.execute((ConnectionCallback) conn -> { conn.setAutoCommit(false); final int replyNo; + try (PreparedStatement ps = conn.prepareStatement("START TRANSACTION")) { + ps.executeUpdate(); + } try (PreparedStatement ps = conn.prepareStatement("SELECT maxreplyid+1 FROM messages WHERE message_id=? FOR UPDATE")) { ps.setInt(1, mid); try (ResultSet resultSet = ps.executeQuery()) { -- cgit v1.2.3