@@ -0,0 +1,2638 @@
+%0A/*%0A * Copyright (C) 2015 Archie L. Cobbs. All rights reserved.%0A */%0A%0Apackage org.jsimpledb;%0A%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.nio.charset.StandardCharsets;%0A%0Aimport org.jsimpledb.annotation.JSimpleClass;%0Aimport org.jsimpledb.annotation.JTransient;%0Aimport org.jsimpledb.core.Database;%0Aimport org.jsimpledb.kv.simple.SimpleKVDatabase;%0Aimport org.jsimpledb.test.TestSupport;%0Aimport org.testng.Assert;%0Aimport org.testng.annotations.DataProvider;%0Aimport org.testng.annotations.Test;%0A%0Apublic class UnknownTypeExistsTest extends TestSupport %7B%0A%0A    @Test%0A    public void testUnknownTypeExists() throws Exception %7B%0A%0A        final Database db = new Database(new SimpleKVDatabase());%0A        final JSimpleDBFactory factory1 = new JSimpleDBFactory();%0A        factory1.setDatabase(db);%0A        factory1.setSchemaVersion(1);%0A        factory1.setModelClasses(Foo.class);%0A        final JSimpleDB jdb1 = factory1.newJSimpleDB();%0A%0A        JTransaction jtx;%0A%0A        jtx = jdb1.createTransaction(true, ValidationMode.AUTOMATIC);%0A        JTransaction.setCurrent(jtx);%0A        final Foo foo1;%0A        final Foo foo2;%0A        try %7B%0A%0A            foo1 = jtx.create(Foo.class);%0A            foo2 = jtx.create(Foo.class);%0A%0A            Assert.assertTrue(foo1.exists());%0A            Assert.assertTrue(foo2.exists());%0A%0A            foo2.delete();%0A%0A            Assert.assertTrue(foo1.exists());%0A            Assert.assertFalse(foo2.exists());%0A%0A            jtx.commit();%0A        %7D finally %7B%0A            JTransaction.setCurrent(null);%0A        %7D%0A%0A        final JSimpleDBFactory factory2 = new JSimpleDBFactory();%0A        factory2.setDatabase(db);%0A        factory2.setSchemaVersion(2);%0A        factory2.setModelClasses(Bar.class);%0A        final JSimpleDB jdb2 = factory2.newJSimpleDB();%0A%0A        jtx = jdb2.createTransaction(true, ValidationMode.AUTOMATIC);%0A        JTransaction.setCurrent(jtx);%0A        final Bar bar;%0A        try %7B%0A%0A            bar = jtx.create(Bar.class);%0A%0A            final JObject foo1x = jtx.get(foo1.getObjId());%0A            final JObject foo2x = jtx.get(foo2.getObjId());%0A%0A            Assert.assertTrue(foo1x instanceof UntypedJObject);%0A            Assert.assertTrue(foo2x instanceof UntypedJObject);%0A%0A            Assert.assertTrue(foo1x.exists());%0A            Assert.assertFalse(foo2x.exists());%0A            Assert.assertTrue(bar.exists());%0A%0A            jtx.commit();%0A        %7D finally %7B%0A            JTransaction.setCurrent(null);%0A        %7D%0A    %7D%0A%0A// Model Classes%0A%0A    @JSimpleClass%0A    public abstract static class Foo implements JObject %7B%0A    %7D%0A%0A    @JSimpleClass%0A    public abstract static class Bar implements JObject %7B%0A    %7D%0A%7D%0A%0A

Add unit test.