-
Notifications
You must be signed in to change notification settings - Fork 620
Description
If the enitity is a Kotlin data class with non nullable values the projection fails.
The following minimal project reproduces the error:
@Node("SomeEntity")
data class SomeEntity(
@Id
val id: String = UUID.randomUUID().toString(),
val propertyOne: String,
val propertyTwo: String
)
interface Projection {
val propertyOne: String
}
@Repository
interface SomeEntityRepository : Neo4jRepository<SomeEntity, String> {
fun findAllProjectedBy(): List<Projection>
}
@SpringBootApplication
class DemoApplication(
private val someEntityRepository: SomeEntityRepository
) : CommandLineRunner {
override fun run(vararg args: String?) {
someEntityRepository.save(SomeEntity(propertyOne = "one", propertyTwo = "two"))
val result = someEntityRepository.findAllProjectedBy()
}
}
fun main(args: Array<String>) {
runApplication<DemoApplication>(*args)
}Error
org.springframework.data.mapping.MappingException: Error mapping Record<{someEntity: {propertyOne: "one", __elementId__: 11019, __nodeLabels__: ["SomeEntity"]}}>
Caused by: org.springframework.data.mapping.model.MappingInstantiationException: Failed to instantiate com.example.demo.SomeEntity using constructor fun (kotlin.String, kotlin.String, kotlin.String): com.example.demo.SomeEntity with arguments null,one,null,1,null
Caused by: java.lang.NullPointerException: Parameter specified as non-null is null: method com.example.demo.SomeEntity.<init>, parameter propertyTwo
Spring Data Neo4j Version: 7.2.5
Neo4J Java Drivder Version: 5.19.0