Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package org.apache.cayenne.dba;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
Expand Down Expand Up @@ -167,10 +166,17 @@ protected String dropAutoPkString() {
protected boolean autoPkTableExists(DataNode node) throws SQLException {

try (Connection con = node.getDataSource().getConnection();) {
DatabaseMetaData md = con.getMetaData();

try (ResultSet tables = md.getTables(null, null, "AUTO_PK_SUPPORT", null);) {
return tables.next();
// Need to use same schema as the insert/update queries will
// use. Could use md.getTables with con.getSchema, but that require
// up to date driver and pool.
String sql = "SELECT * from AUTO_PK_SUPPORT";
try (Statement stm = con.createStatement();) {
stm.setMaxRows(1);
try (ResultSet rs = stm.executeQuery(sql);) {
return true;
} catch (SQLException e) {
return false;
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions docs/doc/src/main/resources/RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ CAY-2023 Decouple the use of ResourceLocator
CAY-2025 Support for DBCP2
CAY-2026 Java 7
CAY-2027 Support for Expression outer join syntax in EJBQL
CAY-2024 Check for AUTO_PK_SUPPORT should respect current schema

Bug Fixes:

Expand Down