summaryrefslogtreecommitdiff
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
parentb7ac911eb0747e43e24c49c4540b5b43e568235e (diff)
Primary key validation is more lenient to support views.
-rw-r--r--RELEASE-NOTES.txt2
-rw-r--r--src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java12
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();
}