neo4j-examples / movies-kotlin-spring-data-neo4j

Neo4j Movies Example with Kotlin, Spring Boot & Spring Data Neo4j
Apache License 2.0
25 stars 12 forks source link

Question: Why are the domain properties var and not val? #4

Open asarkar opened 6 years ago

asarkar commented 6 years ago

Like https://github.com/neo4j-examples/movies-kotlin-spring-data-neo4j/blob/master/src/main/java/movies/spring/data/neo4j/domain/model/persistent/entities/Movie.kt#L10

I've come to realize that declaring the properties as val makes queries not find previously saved entities, although I've not figured out why. Saving seems to work, but not loading.

jasperblues commented 6 years ago

Yep, for idiomatic Kotlin, we'd most likely want them to be val, however for that to work we need 'persistence constructors', which has just been added to OGM/SDN, hence issue #2.

asarkar commented 6 years ago

I saw issue 2, but found no reference to persistence constructors. Would appreciate if you can post a link here. That said, what's the problem with val without persistence constructors?

nmervaillie commented 6 years ago

The problem with val defined attributes is that they end up as final in terms of java code. And this makes them not taken into account by OGM as valid attributes because of some current limitations. Details here