OGM fails to map certain types in Kotlin data class

(Jiropole) #1

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:

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!

(Jiropole) #3

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


(Michael Simons) #4

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).