summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2007-02-21 01:52:36 +0000
committerBrian S. O'Neill <bronee@gmail.com>2007-02-21 01:52:36 +0000
commit557525c89f7db752930754ed654d35d33fe2298a (patch)
treebcbac83b0c4be81aec5f4a461018b98b970814cf /src
parentb7ac911eb0747e43e24c49c4540b5b43e568235e (diff)
Primary key validation is more lenient to support views.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java12
1 files changed, 10 insertions, 2 deletions
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();
}