From 30cc7f1c3943be87573849864f1f0637fd5cc3c6 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Tue, 17 Oct 2006 23:32:59 +0000 Subject: Prevent accidental replication of internal storables. --- src/main/java/com/amazon/carbonado/spi/LobEngine.java | 5 +++-- src/main/java/com/amazon/carbonado/spi/StoredLob.java | 9 ++++----- src/main/java/com/amazon/carbonado/spi/StoredSequence.java | 2 ++ 3 files changed, 9 insertions(+), 7 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 167c5b1..e91bf59 100644 --- a/src/main/java/com/amazon/carbonado/spi/LobEngine.java +++ b/src/main/java/com/amazon/carbonado/spi/LobEngine.java @@ -149,7 +149,7 @@ public class LobEngine { lob.setLocator(locator); if (lob.tryDelete()) { try { - lob.getBlocks().deleteAll(); + mLobBlockStorage.query("locator = ?").with(lob.getLocator()).deleteAll(); } catch (FetchException e) { throw e.toPersistException(); } @@ -579,7 +579,8 @@ public class LobEngine { // Free unused blocks. long newBlockCount = lob.getBlockCount(); if (newBlockCount < oldBlockCount) { - lob.getBlocks().and("blockNumber >= ?") + mLobBlockStorage.query("locator = ? & blockNumber >= ?") + .with(lob.getLocator()) // Subtract 0x80000000 such that block zero is // physically stored with the smallest integer. .with(((int) newBlockCount) - 0x80000000) diff --git a/src/main/java/com/amazon/carbonado/spi/StoredLob.java b/src/main/java/com/amazon/carbonado/spi/StoredLob.java index e081bb3..2435cb1 100644 --- a/src/main/java/com/amazon/carbonado/spi/StoredLob.java +++ b/src/main/java/com/amazon/carbonado/spi/StoredLob.java @@ -18,10 +18,10 @@ package com.amazon.carbonado.spi; +import com.amazon.carbonado.Alias; import com.amazon.carbonado.FetchException; -import com.amazon.carbonado.Join; +import com.amazon.carbonado.Independent; import com.amazon.carbonado.PrimaryKey; -import com.amazon.carbonado.Query; import com.amazon.carbonado.Sequence; import com.amazon.carbonado.Storable; import com.amazon.carbonado.Version; @@ -35,6 +35,8 @@ import com.amazon.carbonado.constraint.IntegerConstraint; * @see LobEngine */ @PrimaryKey("locator") +@Independent +@Alias("CARBONADO_LOB") public abstract class StoredLob implements Storable { @Sequence("com.amazon.carbonado.spi.StoredLob") public abstract long getLocator(); @@ -52,9 +54,6 @@ public abstract class StoredLob implements Storable { public abstract int getVersion(); public abstract void setVersion(int version); - @Join - public abstract Query getBlocks() throws FetchException; - /** * Returns number of blocks required to store Lob. */ diff --git a/src/main/java/com/amazon/carbonado/spi/StoredSequence.java b/src/main/java/com/amazon/carbonado/spi/StoredSequence.java index bcd0a3c..0a5a19e 100644 --- a/src/main/java/com/amazon/carbonado/spi/StoredSequence.java +++ b/src/main/java/com/amazon/carbonado/spi/StoredSequence.java @@ -19,6 +19,7 @@ package com.amazon.carbonado.spi; import com.amazon.carbonado.Alias; +import com.amazon.carbonado.Independent; import com.amazon.carbonado.PrimaryKey; import com.amazon.carbonado.Storable; @@ -28,6 +29,7 @@ import com.amazon.carbonado.Storable; * @author Brian S O'Neill */ @PrimaryKey("name") +@Independent @Alias("CARBONADO_SEQUENCE") public interface StoredSequence extends Storable { String getName(); -- cgit v1.2.3