Using projections as relationship nodes in spring data neo4j returns nothing

Viewed 20

I have two node entitites with a relationship between them. I have usecases to have repository methods for both node types returning also the related one. I've tried to use projections as suggested by the documentation, but can't seem to work anything. I also can't specify the wanted relationship to both entities, since that results in a circular reference.

What I've tried so far is to have interfaces describing both entitites without the relationship like

@Node
data class Foo(
    val name,
    @Relationship(type = "IS", direction = OUTGOING) val bar: BarProjection? = null
)

interface FooProjection {
    val name: String
}

@Node
data class Bar(
    val name,
    @Relationship(type = "IS", direction = INCOMING) val foo: FooProjection? = null
)

interface BarProjection {
    val name
}

But this doesn't return anything for the relationships, as I'm probably using the projections incorrectly. Is there a way to model the relationship both ways so I can use spring data query methods in my repositories or do I need to create custom dao classes and cypher queries ran with the Neo4jClient to achieve this?

0 Answers
Related