cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Using OGM with @NodeEntity(label="...") on interface

OGM (v3.1.1) doesn't seem to support @NodeEntity on an interface class with the label specified explicitly. Let's say, I have an annotated interface:

@NodeEntity(label = "MY_LABEL")
interface MyInterface { ... }

which is implemented by a class MyInterfaceImpl. Now, I can't make OGM map the entity names in the db result (MY_LABEL) to the corresponding java class (MyInterfaceImpl) - there seems to be no mapping "label => interface => implementing class". However, it does work as expected when the label is identical to the interface name.

Am I missing something?

2 REPLIES 2

Jiropole
Graph Voyager

Interesting. Have you tried putting the @NodeEntity annotation on the implementation class?

Thanks, @Jiropole, I did some further research, and indeed:

  • Where interface name != node label, @NodeEntity(label="...") has to be set on the implementation class.
  • On the other hand, where interface name == node label, @NodeEntity (without label=...) needs to be on the interface, otherwise no mapping is found (see https://github.com/neo4j/neo4j-ogm/issues/458).

Not quite self-explaining, I couldn't find any documentation about this, though.