From ef26374e59193718c443f3a50f62d52f307a6453 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Fri, 9 May 2008 05:16:55 +0000 Subject: Support derived version property. --- .../carbonado/repo/jdbc/JDBCStorableGenerator.java | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'src/main/java/com/amazon/carbonado/repo') diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java index 5207452..993b95c 100644 --- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java +++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java @@ -133,6 +133,10 @@ class JDBCStorableGenerator { MasterFeature.INSERT_TXN, // Required because of reload after insert. MasterFeature.UPDATE_TXN); // Required because of reload after update. + if (info.getVersionProperty() != null && info.getVersionProperty().isDerived()) { + features.add(MasterFeature.VERSIONING); + } + if (suppressReload) { // No need to be in a transaction if reload never happens. honorSuppression: { @@ -140,6 +144,9 @@ class JDBCStorableGenerator { info.getIdentityProperties(); for (JDBCStorableProperty prop : mAllProperties.values()) { + if (!prop.isSelectable()) { + continue; + } if (prop.isAutomatic() && !identityProperties.containsKey(prop.getName())) { // Might still need to reload. This could be determined // dynamically, but this is an optimization that be @@ -865,12 +872,16 @@ class JDBCStorableGenerator { mInfo.getPrimaryKeyProperties().values(); JDBCStorableProperty versionProperty = mInfo.getVersionProperty(); - if (versionProperty != null && versionProperty.isSupported()) { - // Include version property in WHERE clause to support optimistic locking. - List> list = - new ArrayList>(whereProperties); - list.add(versionProperty); - whereProperties = list; + if (versionProperty != null) { + if (!versionProperty.isSelectable()) { + versionProperty = null; + } else { + // Include version property in WHERE clause to support optimistic locking. + List> list = + new ArrayList>(whereProperties); + list.add(versionProperty); + whereProperties = list; + } } // If no dirty properties, a valid update statement must still be -- cgit v1.2.3