-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Description
Bug description
I upgraded Spring AI Version from 1.0.0-M7 to 1.0.0-RC1. Before that, I used a custom RedisChatMemory. I found that there is an implementation of JdbcChatMemory in the new version, so I decided to replace RedisChatMemory.
The getSelectMessagesSql() method of MysqlChatMemoryRepositoryDialect requires two parameters, conversation_id and limit, to be passed in, and there is no default value.
public class MysqlChatMemoryRepositoryDialect implements JdbcChatMemoryRepositoryDialect {
@Override
public String getSelectMessagesSql() {
return "SELECT content, type FROM SPRING_AI_CHAT_MEMORY WHERE conversation_id = ? ORDER BY `timestamp` DESC LIMIT ?";
}
However, the upper-level JdbcChatMemoryRepository.findByConversationId(String conversationId) only has one conversation_id parameter.
public class JdbcChatMemoryRepository implements ChatMemoryRepository
@Override
public List<Message> findByConversationId(String conversationId) {
Assert.hasText(conversationId, "conversationId cannot be null or empty");
return this.jdbcTemplate.query(dialect.getSelectMessagesSql(), new MessageRowMapper(), conversationId);
}
so an Exception occurred after I initiated the call.
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT content, type FROM SPRING_AI_CHAT_MEMORY WHERE conversation_id = ? ORDER BY `timestamp` DESC LIMIT ?]
Caused by: java.sql.SQLException: No value specified for parameter 2
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[mysql-connector-java-8.0.19.jar:8.0.19]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.19.jar:8.0.19]
Has anyone else encountered this problem, or is there something wrong with my usage? Please help me solve this problem
Metadata
Metadata
Assignees
Labels
No labels