Skip to content

Add support to define target node class for projections to support multilevel projections with inheritance #2621

@NilsWild

Description

@NilsWild

Problem:
Given the following Node definitions:

@Node
class Foo (
        val bar: Bar
        ) {
    @Id
    var id: UUID = UUID.randomUUID()
}

@Node
open class Bar(
    val value1: String
) {
    @Id
    var id: UUID = UUID.randomUUID()
}

@Node
open class BarBar(value1: String, val value2: String): Bar(value1)

There is no way to define a multi-level projection for Foo and Bar/BarBar that can be saved or queried, because sdn can't determine to which subtype the projection should be mapped and vice versa. e.g.: The following wont work:

class FooProjection(
    val bar: BarProjection
)

open class BarProjection(
    val value1: String
)

open class BarBarProjection(value1: String, val value2: String): BarProjection(value1)

val barBarProjection = BarBarProjection("v1", "v2")
val fooProjection = FooProjection(barBarProjection)
neo4jTemplate.save(Foo::class.java).one(fooProjection)

Querying will result in an exception as well because the mapping information is missing.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions