summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2010-06-08 02:33:09 +0000
committerBrian S. O'Neill <bronee@gmail.com>2010-06-08 02:33:09 +0000
commit41bc565cc82b87d1c1ef9f85705a1fc8fdd6f0f1 (patch)
tree7fe8fc7d2485118908c12365b00b27eadda7ce9d /src/main/java
parent87827c768c2d54cc5e90ba0ecb2342463bce787b (diff)
Fix serialization of adapted primary key properties.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/amazon/carbonado/gen/StorableGenerator.java35
1 files changed, 10 insertions, 25 deletions
diff --git a/src/main/java/com/amazon/carbonado/gen/StorableGenerator.java b/src/main/java/com/amazon/carbonado/gen/StorableGenerator.java
index 8242941..ddde311 100644
--- a/src/main/java/com/amazon/carbonado/gen/StorableGenerator.java
+++ b/src/main/java/com/amazon/carbonado/gen/StorableGenerator.java
@@ -966,9 +966,7 @@ public final class StorableGenerator<S extends Storable> {
// Note: Calling these methods does not affect any state bits.
// They are only intended to be used by subclasses during loading.
- if (property.getAdapter() != null &&
- (!property.isDerived() || (property.getWriteMethod() != null)))
- {
+ if (property.getAdapter() != null && !property.isDerived()) {
// End name with '$' to prevent any possible collisions.
String writeName = property.getWriteMethodName() + '$';
@@ -996,7 +994,9 @@ public final class StorableGenerator<S extends Storable> {
b.loadLocal(b.getParameter(0));
b.invoke(adaptMethod);
- storeProperty(b, property, type);
+ // Always store to field directly, to prevent state
+ // bits from changing.
+ b.storeField(property.getName(), type);
b.returnVoid();
}
@@ -1991,7 +1991,12 @@ public final class StorableGenerator<S extends Storable> {
b.loadLocal(target); // [target
loadThisProperty(b, property, type); // [target, this.propValue
- storeProperty(b, property, type);
+ if (property.getWriteMethod() != null) {
+ // Favor the write method, if it exists.
+ b.invoke(property.getWriteMethod());
+ } else {
+ b.storeField(property.getName(), type);
+ }
skipCopy.setLocation();
}
@@ -2068,26 +2073,6 @@ public final class StorableGenerator<S extends Storable> {
}
/**
- * Puts the value on the stack into the specified storable. If a write
- * method is defined, use it. Otherwise, just shove the value into the
- * appropriate field.
- *
- * entry stack: [storable, value
- * exit stack: [
- *
- * @param b - {@link CodeBuilder} to which to add the mutation code
- * @param property - property to mutate
- * @param type - type of the property
- */
- private void storeProperty(CodeBuilder b, StorableProperty property, TypeDesc type) {
- if (property.getWriteMethod() == null && !property.isDerived()) {
- b.storeField(property.getName(), type);
- } else {
- b.invoke(property.getWriteMethod());
- }
- }
-
- /**
* Generates code that loads a property annotation to the stack.
*/
private void loadPropertyAnnotation(CodeBuilder b,