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. --- .../amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/main') 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