質問

SDN v3.0.0 RELEASE Neo4j Community 2.0.1

I'm having a bit of an issue with regards to inheritance and collections. Perhaps someone could assist with the matter. I basically have the following structure.

public abstract class Graphic;

public class Shape1 extends Graphic;

public class Shape2 extends Graphic;

public class Shape3 extends Graphic;

public class Overlay {

    Set<Graphic> graphics;

}

public interface GraphicsRepository extends GraphRepository<Graphic>{}

I can persist the graphics using the graphic repository and all the various attributes are stored correctly based on the concrete classes. I can query and get individual graphics with the correct attributes, and do various things associate with the classes in the neo4j "portal" environment. But when i do a retrieve on the overlay i only ever get the base class Graphic as the class type within the collection and casting does not work. I could be overlooking something or just not doing something correctly, but figured i would post and see if there was anything that someone could suggest. I've searched google and stack overflow and have only ever found similar issues where it was the main class and never a internal collection of objects.

Also, when i remove abstract from the Graphic class i get the same results⦠All items in the Overlay graphics set are of type Graphic. And adding @TypeAlias does not seem to help.

Thanks

役に立ちましたか?

解決

Ok, i found the issue… kind of feel foolish but i forgot to put @Fetch on the graphic collection. Strangely enough it does retrieve graphic objects but they are all of type Graphic. When i added fetch to the collection, the collection items were retrieved with the correct type.

他のヒント

Actually it should use the type stored in the graph to construct the entity, i.e. the most concrete type (in SDN 3.0.1 it is prepended by a "_", so should be "_Shape1" etc.)

Can you check the labels of the nodes in the graph?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top