Skip to content

Wrong message order for JDBC Chat Memory #3149

@xjh1994

Description

@xjh1994

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())); } 

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions