@@ -0,0 +1,2364 @@
+%0A/*%0A * Copyright (C) 2015 Archie L. Cobbs. All rights reserved.%0A */%0A%0Apackage org.jsimpledb;%0A%0Aimport java.lang.annotation.ElementType;%0Aimport java.lang.annotation.Retention;%0Aimport java.lang.annotation.RetentionPolicy;%0Aimport java.lang.annotation.Target;%0Aimport java.util.List;%0A%0Aimport javax.validation.Constraint;%0Aimport javax.validation.ConstraintValidator;%0Aimport javax.validation.ConstraintValidatorContext;%0Aimport javax.validation.Payload;%0Aimport javax.validation.constraints.Min;%0Aimport javax.validation.constraints.NotNull;%0Aimport javax.validation.constraints.Size;%0A%0Aimport org.jsimpledb.annotation.JField;%0Aimport org.jsimpledb.annotation.JListField;%0Aimport org.jsimpledb.annotation.JSimpleClass;%0Aimport org.jsimpledb.annotation.OnValidate;%0Aimport org.jsimpledb.test.TestSupport;%0Aimport org.testng.Assert;%0Aimport org.testng.annotations.Test;%0A%0Apublic class ValidationInvalidTargetTypeTest extends TestSupport %7B%0A%0A    @Test%0A    public void testValidationInvalidTargetType() %7B%0A%0A        final JSimpleDB jdb = BasicTest.getJSimpleDB(Person1.class, Person2.class);%0A%0A        JTransaction tx = jdb.createTransaction(true, ValidationMode.AUTOMATIC);%0A        JTransaction.setCurrent(tx);%0A        try %7B%0A%0A            Person1 p1 = tx.create(Person1.class);%0A            Person1 p1m = tx.create(Person1.class);%0A%0A            p1.setFriend(p1m);%0A%0A            // A bug was causing the following exception on the following statement:%0A            // java.lang.IllegalArgumentException: invalid target type org.jsimpledb.SelfReferenceTest$HasFriend%0A            //      for index query on field %60friend' in interface org.jsimpledb.SelfReferenceTest$HasFriend:%0A            //      should be a super-type or sub-type of org.jsimpledb.SelfReferenceTest$Person%0A            tx.validate();%0A%0A            tx.commit();%0A        %7D finally %7B%0A            JTransaction.setCurrent(null);%0A        %7D%0A    %7D%0A%0A// Model Classes%0A%0A    public interface HasFriend %7B%0A%0A        @JField(storageId = 200, unique = true)%0A        HasFriend getFriend();%0A        void setFriend(HasFriend person);%0A    %7D%0A%0A    public abstract static class Person implements JObject %7B%0A    %7D%0A%0A    @JSimpleClass(storageId = 100)%0A    public abstract static class Person1 extends Person implements HasFriend %7B%0A    %7D%0A%0A    @JSimpleClass(storageId = 101)%0A    public abstract static class Person2 extends Person implements HasFriend %7B%0A    %7D%0A%7D%0A%0A

Add unit test exposing a bug in validation.