From aad09f3bfe9ce141c409093c5f4f8917cf70ae08 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Thu, 21 Jul 2011 21:51:09 +0000 Subject: Use singleton LayoutFactory for type transport, preventing generation of too many extra classes. --- .../java/com/amazon/carbonado/layout/LayoutFactory.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') 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, 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; -- cgit v1.2.3