From 102f6065f6426e39ca79367c4ec342166a9a676c Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Thu, 20 Dec 2012 16:51:13 +0100 Subject: [PATCH] [#1097] Add org.jooq.Catalog, a type modelling an entity combining several org.jooq.Schema --- jOOQ/src/main/java/org/jooq/Meta.java | 16 +++++++++++++--- jOOQ/src/main/java/org/jooq/impl/MetaImpl.java | 5 +++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/Meta.java b/jOOQ/src/main/java/org/jooq/Meta.java index 69e3add16c..4e9735d050 100644 --- a/jOOQ/src/main/java/org/jooq/Meta.java +++ b/jOOQ/src/main/java/org/jooq/Meta.java @@ -64,22 +64,32 @@ public interface Meta { /** * Get all catalog objects from the underlying {@link DatabaseMetaData} + *

+ * For those databases that don't really support JDBC meta data catalogs, a + * single empty catalog (named "") will be returned. In other + * words, there is always at least one catalog in a database. * - * @throws DataAccessException If something went wrong fetching the meta objects + * @throws DataAccessException If something went wrong fetching the meta + * objects */ + @Support List getCatalogs() throws DataAccessException; /** * Get all schema objects from the underlying {@link DatabaseMetaData} * - * @throws DataAccessException If something went wrong fetching the meta objects + * @throws DataAccessException If something went wrong fetching the meta + * objects */ + @Support List getSchemas() throws DataAccessException; /** * Get all table objects from the underlying {@link DatabaseMetaData} * - * @throws DataAccessException If something went wrong fetching the meta objects + * @throws DataAccessException If something went wrong fetching the meta + * objects */ + @Support List> getTables() throws DataAccessException; } diff --git a/jOOQ/src/main/java/org/jooq/impl/MetaImpl.java b/jOOQ/src/main/java/org/jooq/impl/MetaImpl.java index 719704e5c7..9d6027dd86 100644 --- a/jOOQ/src/main/java/org/jooq/impl/MetaImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/MetaImpl.java @@ -92,6 +92,11 @@ class MetaImpl implements Meta { result.add(new MetaCatalog(name)); } + // There should always be at least one (empty) catalog in a database + if (result.isEmpty()) { + result.add(new MetaCatalog("")); + } + return result; } catch (SQLException e) {