From 97af4be638e371a2f693bde2798fc233a143f3f9 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Sun, 29 Apr 2007 17:47:50 +0000 Subject: Merged in support for derived properties. --- .../carbonado/repo/jdbc/JDBCStorableGenerator.java | 18 ++++++++++-------- .../repo/jdbc/JDBCStorableIntrospector.java | 21 +++++++++++++++++++-- 2 files changed, 29 insertions(+), 10 deletions(-) (limited to 'src/main/java/com/amazon/carbonado/repo/jdbc') 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 2528cbf..57f7bbc 100644 --- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java +++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java @@ -223,7 +223,7 @@ class JDBCStorableGenerator { // UnsupportedOperationException. { for (JDBCStorableProperty property : mAllProperties.values()) { - if (property.isJoin() || property.isSupported()) { + if (property.isDerived() || property.isJoin() || property.isSupported()) { continue; } String message = "Independent property \"" + property.getName() + @@ -444,7 +444,7 @@ class JDBCStorableGenerator { sb.append(" ( "); int ordinal = 0; - for (JDBCStorableProperty property : mInfo.getAllProperties().values()) { + for (JDBCStorableProperty property : mAllProperties.values()) { if (!property.isSelectable()) { continue; } @@ -470,10 +470,12 @@ class JDBCStorableGenerator { } boolean useStaticInsertStatement = true; - for (JDBCStorableProperty property : mInfo.getAllProperties().values()) { - if (property.isVersion() || property.isAutomatic()) { - useStaticInsertStatement = false; - break; + for (JDBCStorableProperty property : mAllProperties.values()) { + if (!property.isDerived()) { + if (property.isVersion() || property.isAutomatic()) { + useStaticInsertStatement = false; + break; + } } } @@ -489,7 +491,7 @@ class JDBCStorableGenerator { insertCountVar = b.createLocalVariable(null, TypeDesc.INT); int initialCount = 0; - for (JDBCStorableProperty property : mInfo.getAllProperties().values()) { + for (JDBCStorableProperty property : mAllProperties.values()) { if (!property.isSelectable()) { continue; } @@ -517,7 +519,7 @@ class JDBCStorableGenerator { CodeBuilderUtil.callStringBuilderAppendString(b); int propNumber = -1; - for (JDBCStorableProperty property : mInfo.getAllProperties().values()) { + for (JDBCStorableProperty property : mAllProperties.values()) { propNumber++; if (!property.isSelectable()) { continue; 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 aa17f11..5ff713d 100644 --- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java +++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java @@ -55,6 +55,7 @@ import com.amazon.carbonado.RepositoryException; import com.amazon.carbonado.Storable; import com.amazon.carbonado.SupportException; +import com.amazon.carbonado.info.ChainedProperty; import com.amazon.carbonado.info.OrderedProperty; import com.amazon.carbonado.info.StorableInfo; import com.amazon.carbonado.info.StorableIntrospector; @@ -277,7 +278,7 @@ public class JDBCStorableIntrospector extends StorableIntrospector { ArrayList errorMessages = new ArrayList(); for (StorableProperty mainProperty : mainProperties.values()) { - if (mainProperty.isJoin() || tableName == null) { + if (mainProperty.isDerived() || mainProperty.isJoin() || tableName == null) { jProperties.put(mainProperty.getName(), new JProperty(mainProperty)); continue; } @@ -1271,6 +1272,10 @@ public class JDBCStorableIntrospector extends StorableIntrospector { return mMainProperty.isJoin(); } + public boolean isOneToOneJoin() { + return mMainProperty.isOneToOneJoin(); + } + public Class getJoinedType() { return mMainProperty.getJoinedType(); } @@ -1315,6 +1320,18 @@ public class JDBCStorableIntrospector extends StorableIntrospector { return mMainProperty.isIndependent(); } + public boolean isDerived() { + return mMainProperty.isDerived(); + } + + public ChainedProperty[] getDerivedFromProperties() { + return mMainProperty.getDerivedFromProperties(); + } + + public ChainedProperty[] getDerivedToProperties() { + return mMainProperty.getDerivedToProperties(); + } + public boolean isSupported() { if (isJoin()) { // TODO: Check if joined type is supported @@ -1325,7 +1342,7 @@ public class JDBCStorableIntrospector extends StorableIntrospector { } public boolean isSelectable() { - return mColumnName != null && !isJoin(); + return mColumnName != null && !isJoin() && !isDerived(); } public boolean isAutoIncrement() { -- cgit v1.2.3