Properly supply the catalog to the metadata.
This commit is contained in:
@@ -1033,25 +1033,25 @@ public class DepotMarshaller<T extends PersistentRecord> implements QueryMarshal
|
|||||||
return ctx.invoke(new Fetcher.Trivial<TableMetaData>() {
|
return ctx.invoke(new Fetcher.Trivial<TableMetaData>() {
|
||||||
public TableMetaData invoke (PersistenceContext ctx, Connection conn,
|
public TableMetaData invoke (PersistenceContext ctx, Connection conn,
|
||||||
DatabaseLiaison dl) throws SQLException {
|
DatabaseLiaison dl) throws SQLException {
|
||||||
return new TableMetaData(conn.getMetaData(), dl, tableName);
|
return new TableMetaData(conn.getCatalog(), conn.getMetaData(), dl, tableName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public TableMetaData (DatabaseMetaData meta, DatabaseLiaison dl, String tableName)
|
public TableMetaData (
|
||||||
throws SQLException
|
String catalog, DatabaseMetaData meta, DatabaseLiaison dl, String tableName
|
||||||
{
|
) throws SQLException {
|
||||||
tableExists = meta.getTables(null, dl.getSchemaName(), tableName, null).next();
|
tableExists = meta.getTables(catalog, dl.getSchemaName(), tableName, null).next();
|
||||||
if (!tableExists) {
|
if (!tableExists) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultSet rs = meta.getColumns(null, dl.getSchemaName(), tableName, "%");
|
ResultSet rs = meta.getColumns(catalog, dl.getSchemaName(), tableName, "%");
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
tableColumns.add(rs.getString("COLUMN_NAME"));
|
tableColumns.add(rs.getString("COLUMN_NAME"));
|
||||||
}
|
}
|
||||||
|
|
||||||
rs = meta.getIndexInfo(null, dl.getSchemaName(), tableName, false, false);
|
rs = meta.getIndexInfo(catalog, dl.getSchemaName(), tableName, false, false);
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
String indexName = rs.getString("INDEX_NAME");
|
String indexName = rs.getString("INDEX_NAME");
|
||||||
Set<String> set = indexColumns.get(indexName);
|
Set<String> set = indexColumns.get(indexName);
|
||||||
@@ -1071,7 +1071,7 @@ public class DepotMarshaller<T extends PersistentRecord> implements QueryMarshal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rs = meta.getPrimaryKeys(null, dl.getSchemaName(), tableName);
|
rs = meta.getPrimaryKeys(catalog, dl.getSchemaName(), tableName);
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
pkName = rs.getString("PK_NAME");
|
pkName = rs.getString("PK_NAME");
|
||||||
pkColumns.add(rs.getString("COLUMN_NAME"));
|
pkColumns.add(rs.getString("COLUMN_NAME"));
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public abstract class BaseLiaison implements DatabaseLiaison
|
|||||||
// from DatabaseLiaison
|
// from DatabaseLiaison
|
||||||
public boolean tableExists (Connection conn, String name) throws SQLException
|
public boolean tableExists (Connection conn, String name) throws SQLException
|
||||||
{
|
{
|
||||||
ResultSet rs = conn.getMetaData().getTables(null, getSchemaName(), name, null);
|
ResultSet rs = conn.getMetaData().getTables(conn.getCatalog(), getSchemaName(), name, null);
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
String tname = rs.getString("TABLE_NAME");
|
String tname = rs.getString("TABLE_NAME");
|
||||||
if (name.equals(tname)) {
|
if (name.equals(tname)) {
|
||||||
@@ -81,7 +81,8 @@ public abstract class BaseLiaison implements DatabaseLiaison
|
|||||||
public boolean tableContainsColumn (Connection conn, String table, String column)
|
public boolean tableContainsColumn (Connection conn, String table, String column)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
ResultSet rs = conn.getMetaData().getColumns(null, getSchemaName(), table, column);
|
ResultSet rs = conn.getMetaData().getColumns(
|
||||||
|
conn.getCatalog(), getSchemaName(), table, column);
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
String tname = rs.getString("TABLE_NAME");
|
String tname = rs.getString("TABLE_NAME");
|
||||||
String cname = rs.getString("COLUMN_NAME");
|
String cname = rs.getString("COLUMN_NAME");
|
||||||
@@ -96,7 +97,8 @@ public abstract class BaseLiaison implements DatabaseLiaison
|
|||||||
public boolean tableContainsIndex (Connection conn, String table, String index)
|
public boolean tableContainsIndex (Connection conn, String table, String index)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
ResultSet rs = conn.getMetaData().getIndexInfo(null, getSchemaName(), table, false, true);
|
ResultSet rs = conn.getMetaData().getIndexInfo(
|
||||||
|
conn.getCatalog(), getSchemaName(), table, false, true);
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
String tname = rs.getString("TABLE_NAME");
|
String tname = rs.getString("TABLE_NAME");
|
||||||
String iname = rs.getString("INDEX_NAME");
|
String iname = rs.getString("INDEX_NAME");
|
||||||
|
|||||||
Reference in New Issue
Block a user