Skip to content

Commit 7631abe

Browse files
committed
CAY-2885 Modeler: DbImport fails to load DB schema view
1 parent 68a91fc commit 7631abe

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

RELEASE-NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ CAY-2872 CayenneModeler "Documentation" link is broken
2525
CAY-2876 Memory leak in the ObjectStore
2626
CAY-2879 Negative number for non parameterized ObjectSelect query not processed correctly
2727
CAY-2883 License and notice templates are not processed by the Gradle build
28+
CAY-2885 Modeler: DbImport fails to load DB schema view
2829

2930
----------------------------------
3031
Release: 5.0-M1

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 6 additions & 2 deletions
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)