spring-projects/spring-ai · info

Explicitly set dialect + explicitDialect.getClass().getSimpl

Error message

Explicitly set dialect + explicitDialect.getClass().getSimpleName() + will be used instead of detected dialect + detected.getClass().getSimpleName() + from datasource

What it means

warnIfDialectMismatch() (invoked from resolveDialect) compares the explicitly configured JdbcChatMemoryRepositoryDialect with the dialect auto-detected from the DataSource metadata. When they differ, it logs this warning telling you the explicit configuration wins. It is informational: your configured dialect will be used even though the database looks like another vendor.

Source

Thrown at memory-repositories/spring-ai-model-chat-memory-repository-jdbc/src/main/java/org/springframework/ai/chat/memory/repository/jdbc/JdbcChatMemoryRepository.java:269

		private JdbcChatMemoryRepositoryDialect resolveDialect(DataSource dataSource) {
			if (this.dialect == null) {
				return JdbcChatMemoryRepositoryDialect.from(dataSource);
			}
			else {
				warnIfDialectMismatch(dataSource, this.dialect);
				return this.dialect;
			}
		}

		/**
		 * Logs a warning if the explicitly set dialect differs from the dialect detected
		 * from the DataSource.
		 */
		private void warnIfDialectMismatch(DataSource dataSource, JdbcChatMemoryRepositoryDialect explicitDialect) {
			JdbcChatMemoryRepositoryDialect detected = JdbcChatMemoryRepositoryDialect.from(dataSource);
			if (!detected.getClass().equals(explicitDialect.getClass())) {
				if (logger.isWarnEnabled()) {
					logger.warn("Explicitly set dialect " + explicitDialect.getClass().getSimpleName()
							+ " will be used instead of detected dialect " + detected.getClass().getSimpleName()
							+ " from datasource");
				}
			}
		}

	}

}

View on GitHub (pinned to 98a7beda4f)

Solutions

  1. Remove the explicit dialect setting so the repository auto-detects from the DataSource, if detection is correct for your DB
  2. If the explicit dialect is intentional (e.g. compatible database using another vendor's SQL), ignore the warning or confirm the SQL generated actually works
  3. Check your datasource URL/credentials — the warning often reveals the app is connected to a different database than you think
  4. If detection misidentifies your database, keep the explicit dialect and file an issue to extend JdbcChatMemoryRepositoryDialect.from()

Example fix

// before: explicit dialect against a detected MySQL datasource
JdbcChatMemoryRepository.builder()
    .dialect(new PostgresChatMemoryRepositoryDialect())
    .build();

// after: let detection choose
JdbcChatMemoryRepository.builder()
    .dataSource(dataSource)
    .build();
Defensive patterns

Strategy: validation

Validate before calling

JdbcChatMemoryRepositoryDialect detected = JdbcChatMemoryRepositoryDialect.from(dataSource);
if (!detected.getClass().equals(configuredDialect.getClass())) {
    logger.warn("Configured dialect {} != detected {}", configuredDialect.getClass().getSimpleName(), detected.getClass().getSimpleName());
}

Prevention

When it happens

Trigger: Setting an explicit dialect (e.g. via JdbcChatMemoryRepository.builder().dialect(new PostgresChatMemoryRepositoryDialect()) or auto-configuration properties) while connecting to a different database vendor (e.g. MySQL), or the detection logic misclassifying your database.

Common situations: Copy-pasted configuration from a Postgres project used against MySQL/SQL Server; shared datasource pointing at a different DB than expected; using a custom/forked dialect subclass; embedded/test databases differing from production config.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


AI-assisted analysis of spring-projects/spring-ai@98a7beda4f (2026-09-11). Data as JSON: /api/errors/8e5d91c3e1cedcd7. Report an issue: GitHub.