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.

OGM fails to map certain types in Kotlin data class

Jiropole
Graph Voyager

I noticed that my String @Properties were mapping fine, but not a FloatArray. In fact, only first two strings get mapped – even if the third property is a String, it isn't mapped. However, this object also contains a FloatArray, so I suspect that once the enumeration gets tripped up, it gives up entirely.

The root of the problem seems to start way down in how Java enumerates annotations with getDeclaredAnnotations. Here's a simple class that exhibits the problem:

@NodeEntity
data class Point(@Id @GeneratedValue(strategy = UuidStrategy::class) val uuid: String? = null,
                 @Property(name = "name") val name: String? = null,
                 @Property(name = "vector") val vector: FloatArray? = null

uuid and name get properly mapped, vector is always null. If I instead define Point as a java class, everything works as expected. I also tried replacing FloatArray with java.util.List<java.lang.Float>, to no avail. Any ideas?

Thanks in advance, ya'll!

1 ACCEPTED SOLUTION

Jiropole
Graph Voyager

Derp, this was due to inadvertently declaring some as val versus var, and not an issue with K-types.

Solved.

View solution in original post

5 REPLIES 5

Jiropole
Graph Voyager

Derp, this was due to inadvertently declaring some as val versus var, and not an issue with K-types.

Solved.

If you're using OGM with SDN, you can keep your standard attributes final and construct stuff via constructor with SDN 5.1 (Lovelace) and OGM 3.1.x. Not supported for relationships (collection attributes).

Does the same apply when you use OGM 3.1.x without SDN?

The constructor support only exists in Spring Data Neo4j right now.

That's a shame. Are there any plans for porting this functionality to OGM itself? If so, is there an issue/ticket where I can keep track of the progress?