From 557525c89f7db752930754ed654d35d33fe2298a Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Wed, 21 Feb 2007 01:52:36 +0000 Subject: Primary key validation is more lenient to support views. --- RELEASE-NOTES.txt | 2 ++ .../amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 1d9d7ca..1a501f9 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -12,6 +12,8 @@ Carbonado change history master, downstream triggers would not see changes made by earlier triggers. - Index creation does a better job of picking up where it left off, avoiding unnecessary delete/insert pairs. +- JDBCRepository is more lenient with primary key validation. This allows + Storables to be more easily mapped to views. 1.1-BETA9 to 1.1-BETA10 ------------------------------- diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java index 4083693..987c809 100644 --- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java +++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java @@ -466,7 +466,15 @@ public class JDBCStorableIntrospector extends StorableIntrospector { } try { - while (rs.next()) { + if (!rs.next()) { + // If no primary keys are reported, don't even bother checking. + // There's no consistent way to get primary keys, and entities + // like views and synonyms don't usually report primary keys. + // A primary key might even be logically defined as a unique + // constraint. + break checkPrimaryKey; + } + do { String columnName = rs.getString("COLUMN_NAME"); String propertyName = columnToProperty.remove(columnName); StorableProperty mainProperty = mainProperties.get(propertyName); @@ -476,7 +484,7 @@ public class JDBCStorableIntrospector extends StorableIntrospector { ("Property \"" + propertyName + "\" must have a PrimaryKey annotation"); } - } + } while (rs.next()); } finally { rs.close(); } -- cgit v1.2.3