summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/repo/jdbc
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/amazon/carbonado/repo/jdbc')
-rw-r--r--src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java18
-rw-r--r--src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java21
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() {