- 
                Notifications
    
You must be signed in to change notification settings  - Fork 2k
 
Oracle: add OracleChatMemory support #3601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e29a4f6
              5b62ffe
              88e02b4
              28e6f0a
              b1026d9
              beaf047
              1b18954
              b6f6d3f
              328883d
              c923373
              801a5fe
              529bb20
              4a0ebe9
              663e27e
              a29b931
              07fd54f
              52b9536
              a0c0b49
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -50,13 +50,7 @@ | |
| <artifactId>spring-jdbc</artifactId> | ||
| </dependency> | ||
| 
     | 
||
| <dependency> | ||
| <groupId>com.zaxxer</groupId> | ||
| <artifactId>HikariCP</artifactId> | ||
| </dependency> | ||
| 
     | 
||
| <!-- TESTING --> | ||
| 
     | 
||
| <dependency> | ||
| <groupId>org.postgresql</groupId> | ||
| <artifactId>postgresql</artifactId> | ||
| 
          
            
          
           | 
    @@ -85,6 +79,20 @@ | |
| <optional>true</optional> | ||
| </dependency> | ||
| 
     | 
||
| <!-- Oracle JDBC Driver --> | ||
| <dependency> | ||
| <groupId>com.oracle.database.jdbc</groupId> | ||
| <artifactId>ojdbc11</artifactId> | ||
| <version>23.9.0.25.07</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| 
     | 
||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter-jdbc</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| 
     | 
||
| <dependency> | ||
| <groupId>org.xerial</groupId> | ||
| <artifactId>sqlite-jdbc</artifactId> | ||
| 
        
          
        
         | 
    @@ -111,6 +119,14 @@ | |
| <scope>test</scope> | ||
| </dependency> | ||
| 
     | 
||
| <!-- Testcontainers for Oracle --> | ||
| <dependency> | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ran into issues when dropping table using this test container. Switched to use the latest   | 
||
| <groupId>org.testcontainers</groupId> | ||
| <artifactId>oracle-xe</artifactId> | ||
| <version>1.19.0</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| 
     | 
||
| <dependency> | ||
| <groupId>org.testcontainers</groupId> | ||
| <artifactId>postgresql</artifactId> | ||
| 
          
            
          
           | 
    ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /* | ||
| * Copyright 2024-2025 the original author or authors. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| 
     | 
||
| package org.springframework.ai.chat.memory.repository.jdbc; | ||
| 
     | 
||
| /** | ||
| * Dialect for Oracle. | ||
| * | ||
| * @author Xiaotong Fan | ||
| * @since 1.1.0 | ||
| */ | ||
| 
     | 
||
| public class OracleChatMemoryRepositoryDialect implements JdbcChatMemoryRepositoryDialect { | ||
| 
     | 
||
| @Override | ||
| public String getSelectMessagesSql() { | ||
| return "SELECT content, type FROM SPRING_AI_CHAT_MEMORY WHERE CONVERSATION_ID = ? ORDER BY \"TIMESTAMP\""; | ||
| } | ||
| 
     | 
||
| @Override | ||
| public String getInsertMessageSql() { | ||
| return "INSERT INTO SPRING_AI_CHAT_MEMORY (CONVERSATION_ID, CONTENT, TYPE, \"TIMESTAMP\") VALUES (?, ?, ?, ?)"; | ||
| } | ||
| 
     | 
||
| @Override | ||
| public String getSelectConversationIdsSql() { | ||
| return "SELECT DISTINCT conversation_id FROM SPRING_AI_CHAT_MEMORY"; | ||
| } | ||
| 
     | 
||
| @Override | ||
| public String getDeleteMessagesSql() { | ||
| return "DELETE FROM SPRING_AI_CHAT_MEMORY WHERE CONVERSATION_ID = ?"; | ||
| } | ||
| 
     | 
||
| } | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| DROP TABLE SPRING_AI_CHAT_MEMORY; | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to use   | 
||
| 
     | 
||
| CREATE TABLE SPRING_AI_CHAT_MEMORY ( | ||
| CONVERSATION_ID VARCHAR2(36 CHAR) NOT NULL, | ||
| CONTENT CLOB NOT NULL, | ||
| "TYPE" VARCHAR2(10 CHAR) NOT NULL CHECK ( | ||
| "TYPE" IN ( | ||
| 'USER', | ||
| 'ASSISTANT', | ||
| 'SYSTEM', | ||
| 'TOOL' | ||
| ) | ||
| ), | ||
| "TIMESTAMP" TIMESTAMP NOT NULL | ||
| ); | ||
| 
     | 
||
| CREATE INDEX SPRING_AI_CHAT_MEMORY_CONVERSATION_ID_TIMESTAMP_IDX | ||
| ON SPRING_AI_CHAT_MEMORY( | ||
| CONVERSATION_ID, | ||
| 'TIMESTAMP' | ||
| ); | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /* | ||
| * Copyright 2023-2025 the original author or authors. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| 
     | 
||
| package org.springframework.ai.chat.memory.repository.jdbc; | ||
| 
     | 
||
| import org.springframework.boot.test.context.SpringBootTest; | ||
| import org.springframework.test.context.TestPropertySource; | ||
| import org.springframework.test.context.jdbc.Sql; | ||
| 
     | 
||
| /** | ||
| * Integration tests for {@link JdbcChatMemoryRepository} with Oracle. | ||
| * | ||
| * @author Xiaotong Fan | ||
| */ | ||
| 
     | 
||
| @SpringBootTest | ||
| @TestPropertySource(properties = { "spring.datasource.url=jdbc:oracle:thin:@localhost:1521/FREEPDB1", | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to use test containers for the test. Will fix when merging.  | 
||
| "spring.datasource.username=scott", "spring.datasource.password=tiger" }) | ||
| @Sql(scripts = "classpath:org/springframework/ai/chat/memory/repository/jdbc/schema-oracle.sql") | ||
| public class JdbcChatMemoryRepositoryOracleIT extends AbstractJdbcChatMemoryRepositoryIT { | ||
| 
     | 
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we prefer to use the test containers this dependency isn't required. Will remove when merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meant to post it for the test container dependency not the JDBC driver one. Will keep this in.