I have a hierarchy like this:
Code:
@NodeEntity public class DummyBase {
	@GraphId 	Long id;	
	public Long getId() { return id; }
}

public class DummySub extends DummyBase {}
And a repository for DummyBase:
Code:
public interface DummyBaseRepository extends GraphRepository<DummyBase> {}
When I persist an instance of DummySub, I can get it back by its id:
Code:
DummySub dummySub = new DummySub().persist();
Long id = dummySub.getId();
DummyBase dummyBase = dummyBaseRepo.findOne(id);
System.out.printf("%d %s\n", id, dummyBase.getClass().getName()); // it says: "123 DummySub"
When I run the application once again and just try to get persisted entity by its known id, its type is DummyBase:
Code:
Long id = 123; // correct id here
DummyBase dummyBase = dummyBaseRepo.findOne(id);
System.out.printf("%s\n", dummyBase.getClass().getName()); // it now says: "DummyBase"
I've also checked the database with Neoclipse and the type of that entity was DummySub, so it looks like problem is related with type mapping logic. I've also debugged it a little and it appeared that type alias is read correctly (the class name is DummySub), but then its base is used instead because Neo4jMappingContext::getPersistentEntity returns null (it only has DummyBase within its persistentEntities).

It works fine within single application run/single application context, so the only way to reproduce it is to have 2 separate contexts both having the same configuration (one for writing and one for reading). I didn't manage to get 2 contexts work (after the first one is created, the second one fails to resolve dependencies), so I can only reproduce it in 2 application runs.

I believe that workaround here is to persist at least one instance of each subclass in hierarchy on every application run, so that these types appear in persistentEntities and then resolved.

Is this a bug?