Skip to content

Commit 8bcc7fc

Browse files
committed
CAY-2885 Modeler: DbImport fails to load DB schema view
1 parent b84148e commit 8bcc7fc

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

RELEASE-NOTES.txt

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ CAY-2884 Upgrade gradle to 8.13
1818
Bug Fixes:
1919

2020
CAY-2883 License and notice templates are not processed by the Gradle build
21+
CAY-2885 Modeler: DbImport fails to load DB schema view
2122

2223
----------------------------------
2324
Release: 4.2.2

modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/LoadDbSchemaAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ private void loadDataBase(DBConnectionInfo connectionInfo) throws Exception {
128128

129129
private void loadTables(DBConnectionInfo connectionInfo,
130130
TreePath tablePath,
131-
DbImportView rootParent) throws SQLException {
131+
DbImportView rootParent) throws Exception {
132132
ReverseEngineering databaseReverseEngineering = new DatabaseSchemaLoader()
133133
.loadTables(connectionInfo,
134134
getApplication().getClassLoadingService(),

modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbimport/DatabaseSchemaLoader.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,10 @@ private void processSchemas(Connection connection,
125125
public ReverseEngineering loadTables(DBConnectionInfo connectionInfo,
126126
ClassLoadingService loadingService,
127127
TreePath path,
128-
String[] tableTypesFromConfig) throws SQLException {
128+
String[] tableTypesFromConfig) throws Exception {
129129
int pathIndex = 1;
130130
String catalogName = null, schemaName = null;
131+
DbAdapter adapter = connectionInfo.makeAdapter(loadingService);
131132

132133
Object userObject = getUserObjectOrNull(path, pathIndex);
133134
if (userObject != null) {
@@ -158,7 +159,10 @@ public ReverseEngineering loadTables(DBConnectionInfo connectionInfo,
158159
String table = resultSet.getString("TABLE_NAME");
159160
String schema = resultSet.getString("TABLE_SCHEM");
160161
String catalog = resultSet.getString("TABLE_CAT");
161-
packTable(table, catalog == null ? catalogName : catalog, schema, null);
162+
String realCatalogName = catalog == null || !adapter.supportsCatalogsOnReverseEngineering()
163+
? catalogName
164+
: catalog;
165+
packTable(table, realCatalogName, schema, null);
162166
}
163167
if (!hasTables && (catalogName != null || schemaName != null)) {
164168
packFilterContainer(catalogName, schemaName);

0 commit comments

Comments
 (0)