Detect current schema as indicated by JDBC Connection

Closes gh-28723
This commit is contained in:
Juergen Hoeller
2023-11-24 23:24:20 +01:00
parent 15d9d9d06a
commit 6ff75f157b

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2023 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.
@@ -30,15 +30,22 @@ import org.springframework.lang.Nullable;
* This class is intended for internal use by the Simple JDBC classes.
*
* @author Thomas Risberg
* @author Juergen Hoeller
* @since 2.5
*/
public class PostgresCallMetaDataProvider extends GenericCallMetaDataProvider {
private static final String RETURN_VALUE_NAME = "returnValue";
private final String schemaName;
public PostgresCallMetaDataProvider(DatabaseMetaData databaseMetaData) throws SQLException {
super(databaseMetaData);
// Use current schema (or public schema) if no schema specified
String schema = databaseMetaData.getConnection().getSchema();
this.schemaName = (schema != null ? schema : "public");
}
@@ -60,8 +67,7 @@ public class PostgresCallMetaDataProvider extends GenericCallMetaDataProvider {
@Override
@Nullable
public String metaDataSchemaNameToUse(@Nullable String schemaName) {
// Use public schema if no schema specified
return (schemaName == null ? "public" : super.metaDataSchemaNameToUse(schemaName));
return (schemaName == null ? this.schemaName : super.metaDataSchemaNameToUse(schemaName));
}
@Override