- Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Description
Every time a new message is generated in the same conversation, all previous messages will be deleted first and then inserted.
public void saveAll(String conversationId, List<Message> messages) { // …… this.deleteByConversationId(conversationId); this.jdbcTemplate.batchUpdate(this.dialect.getInsertMessageSql(), new AddBatchPreparedStatement(conversationId, messages)); }
While timestamp
in AddBatchPreparedStatement is set to current time every time, which leads to the same timestamp for each messages in this conversation.
public void setValues(PreparedStatement ps, int i) throws SQLException { // …… ps.setTimestamp(4, new Timestamp(this.instantSeq.getAndIncrement())); }