diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2007-04-29 17:47:50 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2007-04-29 17:47:50 +0000 |
commit | 97af4be638e371a2f693bde2798fc233a143f3f9 (patch) | |
tree | 533f5d02f91eaf1db500ed4480be23b1712d214d /src/main/java/com/amazon/carbonado/repo/jdbc | |
parent | 1f04eea48231dbc29ed39c100a9d4a7c7f8a8b37 (diff) |
Merged in support for derived properties.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/repo/jdbc')
-rw-r--r-- | src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java | 18 | ||||
-rw-r--r-- | src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java | 21 |
2 files changed, 29 insertions, 10 deletions
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<S extends Storable> { // UnsupportedOperationException.
{
for (JDBCStorableProperty<S> 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<S extends Storable> { 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<S extends Storable> { }
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<S extends Storable> { 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<S extends Storable> { 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<String> errorMessages = new ArrayList<String>();
for (StorableProperty<S> mainProperty : mainProperties.values()) {
- if (mainProperty.isJoin() || tableName == null) {
+ if (mainProperty.isDerived() || mainProperty.isJoin() || tableName == null) {
jProperties.put(mainProperty.getName(), new JProperty<S>(mainProperty));
continue;
}
@@ -1271,6 +1272,10 @@ public class JDBCStorableIntrospector extends StorableIntrospector { return mMainProperty.isJoin();
}
+ public boolean isOneToOneJoin() {
+ return mMainProperty.isOneToOneJoin();
+ }
+
public Class<? extends Storable> getJoinedType() {
return mMainProperty.getJoinedType();
}
@@ -1315,6 +1320,18 @@ public class JDBCStorableIntrospector extends StorableIntrospector { return mMainProperty.isIndependent();
}
+ public boolean isDerived() {
+ return mMainProperty.isDerived();
+ }
+
+ public ChainedProperty<S>[] 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() {
|