From 5be9a7ea0f9aad9e97c4d70cb82ce8a22f2d412a Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Fri, 15 Apr 2011 21:43:54 +0000 Subject: Allow server to supply sequence generated primary key values. --- .../java/com/amazon/carbonado/gen/MasterFeature.java | 3 +++ .../carbonado/gen/MasterStorableGenerator.java | 20 ++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) (limited to 'src/main/java/com') 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 { // 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 { 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(); } -- cgit v1.2.3