summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/layout
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2011-07-21 21:51:09 +0000
committerBrian S. O'Neill <bronee@gmail.com>2011-07-21 21:51:09 +0000
commitaad09f3bfe9ce141c409093c5f4f8917cf70ae08 (patch)
treeba55507e6ec4ee8bd495287838a52b7c3aa12509 /src/main/java/com/amazon/carbonado/layout
parenta05e568387db065a709530b72744174dbe9b9802 (diff)
Use singleton LayoutFactory for type transport, preventing generation of too many extra classes.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/layout')
-rw-r--r--src/main/java/com/amazon/carbonado/layout/LayoutFactory.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/main/java/com/amazon/carbonado/layout/LayoutFactory.java b/src/main/java/com/amazon/carbonado/layout/LayoutFactory.java
index c52d0b8..d03b80c 100644
--- a/src/main/java/com/amazon/carbonado/layout/LayoutFactory.java
+++ b/src/main/java/com/amazon/carbonado/layout/LayoutFactory.java
@@ -74,6 +74,10 @@ public class LayoutFactory implements LayoutCapability {
private SoftValuedCache<Class<? extends Storable>, Layout> mReconstructed;
+ // Added this to allow consumers of the the main Carbonado to deal which
+ // changes to how LayoutFactories are reconstructed from streams.
+ public static final int VERSION = 2;
+
/**
* @throws com.amazon.carbonado.SupportException if underlying repository
* does not support the storables for persisting storable layouts
@@ -371,9 +375,17 @@ public class LayoutFactory implements LayoutCapability {
} catch (UniqueConstraintException e) {
StoredLayout existing = mLayoutStorage.prepare();
storedLayout.copyPrimaryKeyProperties(existing);
- if (!existing.tryLoad() || !existing.equalProperties(storedLayout)) {
+ if (!existing.tryLoad()) {
+ throw e;
+ }
+ // Only check subset of primary and alternate keys. The check
+ // of layout properties is more important.
+ if (!(existing.getLayoutID() == storedLayout.getLayoutID() &&
+ existing.getStorableTypeName().equals(storedLayout.getStorableTypeName())))
+ {
throw e;
}
+ storedLayout = existing;
}
int op;