From d025e69cce3ff409c0d45a821245800a830609cf Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Sun, 16 Mar 2008 23:48:13 +0000 Subject: Support updates to replicated LOBs. --- .../java/com/amazon/carbonado/spi/LobEngine.java | 33 ++++++++++------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'src/main/java/com/amazon/carbonado/spi') diff --git a/src/main/java/com/amazon/carbonado/spi/LobEngine.java b/src/main/java/com/amazon/carbonado/spi/LobEngine.java index 8cc1bf9..e6fcb07 100644 --- a/src/main/java/com/amazon/carbonado/spi/LobEngine.java +++ b/src/main/java/com/amazon/carbonado/spi/LobEngine.java @@ -155,7 +155,8 @@ public class LobEngine { if (lob == null) { return 0; } - return ((LobImpl) lob).getLocator(); + Long locator = (Long) lob.getLocator(); + return locator == null ? 0 : locator; } /** @@ -468,12 +469,8 @@ public class LobEngine { return trigger; } - private interface LobImpl extends Lob { - long getLocator(); - } - - private class BlobImpl extends AbstractBlob implements LobImpl { - final long mLocator; + private class BlobImpl extends AbstractBlob implements Lob { + final Long mLocator; final StoredLob mStoredLob; BlobImpl(long locator) { @@ -648,9 +645,13 @@ public class LobEngine { } } + public Long getLocator() { + return mLocator; + } + @Override public int hashCode() { - return ((int) (mLocator >> 32)) ^ ((int) mLocator); + return mLocator.hashCode(); } @Override @@ -660,7 +661,7 @@ public class LobEngine { } if (obj instanceof BlobImpl) { BlobImpl other = (BlobImpl) obj; - return LobEngine.this == other.getEnclosing() && mLocator == other.mLocator; + return LobEngine.this == other.getEnclosing() && mLocator.equals(other.mLocator); } return false; } @@ -670,16 +671,12 @@ public class LobEngine { return "Blob@" + getLocator(); } - public long getLocator() { - return mLocator; - } - LobEngine getEnclosing() { return LobEngine.this; } } - private class ClobImpl extends BlobClob implements LobImpl { + private class ClobImpl extends BlobClob implements Lob { ClobImpl(long locator) { super(new BlobImpl(locator)); } @@ -688,6 +685,10 @@ public class LobEngine { super(new BlobImpl(lob)); } + public Long getLocator() { + return ((BlobImpl) super.getWrappedBlob()).getLocator(); + } + @Override public int hashCode() { return super.getWrappedBlob().hashCode(); @@ -709,10 +710,6 @@ public class LobEngine { return "Clob@" + getLocator(); } - public long getLocator() { - return ((BlobImpl) super.getWrappedBlob()).getLocator(); - } - // Override to gain permission. protected BlobImpl getWrappedBlob() { return (BlobImpl) super.getWrappedBlob(); -- cgit v1.2.3