Hello, I'm having a issue with transient fields: a...
# spring
v
Hello, I'm having a issue with transient fields: as I've seen in Java JPA @Document @Transient fields moved to use the transient java keyword, in Kotlin there's only the annotation. Is it supposed to work in Kotlin with @Transient or there is another trick to do that?
a
if you are declaring fields in the constructor you should use @field:Transient
if you use just @Transient you are annotating the parameter
t
👍
v
@agomez hey, thanks
but it is not working 😕
it also would be very strange, if @Transient doesnt apply to the field why @Id applies?
here a smaller version of a data class with the issue:
Copy code
@Document(collection = "company")
data class Company(@Id val id: Int,
                   @field:Transient
                   val citiesIds: List<Int>)
I'll try with the field declaration, to see if it works
a
never used JPA Transient in kotlin
class Person(@field:Column(nullable = false, length = 100, unique = true) var name: String)
that's the way i used Columns in the constructor declaration