diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2011-04-15 21:43:54 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2011-04-15 21:43:54 +0000 |
commit | 5be9a7ea0f9aad9e97c4d70cb82ce8a22f2d412a (patch) | |
tree | 8bc8e19814fb57d86034a1b51cecc6868681e841 /src/main | |
parent | 6e16419c18da08323e6f6177c9065ccf1dfd1eaf (diff) |
Allow server to supply sequence generated primary key values.
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/amazon/carbonado/gen/MasterFeature.java | 3 | ||||
-rw-r--r-- | src/main/java/com/amazon/carbonado/gen/MasterStorableGenerator.java | 20 |
2 files changed, 15 insertions, 8 deletions
diff --git a/src/main/java/com/amazon/carbonado/gen/MasterFeature.java b/src/main/java/com/amazon/carbonado/gen/MasterFeature.java index 8d7211e..90e7751 100644 --- a/src/main/java/com/amazon/carbonado/gen/MasterFeature.java +++ b/src/main/java/com/amazon/carbonado/gen/MasterFeature.java @@ -49,6 +49,9 @@ public enum MasterFeature { */
INSERT_CHECK_REQUIRED,
+ /** Insert operation never checks if primary key is filled in. */
+ INSERT_NO_CHECK_PRIMARY_PK,
+
/** Ensure insert operation always is in a transaction. */
INSERT_TXN,
diff --git a/src/main/java/com/amazon/carbonado/gen/MasterStorableGenerator.java b/src/main/java/com/amazon/carbonado/gen/MasterStorableGenerator.java index ef73a2c..791a754 100644 --- a/src/main/java/com/amazon/carbonado/gen/MasterStorableGenerator.java +++ b/src/main/java/com/amazon/carbonado/gen/MasterStorableGenerator.java @@ -344,8 +344,9 @@ public final class MasterStorableGenerator<S extends Storable> { // Add required protected doTryInsert method.
{
if (mFeatures.contains(MasterFeature.PARTITIONING) ||
- mFeatures.contains(MasterFeature.INSERT_SEQUENCES)) {
-
+ mFeatures.contains(MasterFeature.INSERT_SEQUENCES) ||
+ mFeatures.contains(MasterFeature.INSERT_NO_CHECK_PRIMARY_PK))
+ {
MethodInfo mi = mClassFile.addMethod
(Modifiers.PROTECTED,
StorableGenerator.CHECK_PK_FOR_INSERT_METHOD_NAME,
@@ -441,14 +442,17 @@ public final class MasterStorableGenerator<S extends Storable> { ordinal++;
}
- // We've tried our best to fill in missing values, now run the
- // original check method.
+ // We've tried our best to fill in missing values, so now
+ // run the original check method, if required to.
+ }
+
+ if (!mFeatures.contains(MasterFeature.INSERT_NO_CHECK_PRIMARY_PK)) {
+ b.loadThis();
+ b.invokeSuper(mClassFile.getSuperClassName(),
+ StorableGenerator.CHECK_PK_FOR_INSERT_METHOD_NAME,
+ null, null);
}
- b.loadThis();
- b.invokeSuper(mClassFile.getSuperClassName(),
- StorableGenerator.CHECK_PK_FOR_INSERT_METHOD_NAME,
- null, null);
b.returnVoid();
}
|