https://kotlinlang.org logo
#spring
Title
v

villela

10/06/2017, 7:28 PM
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

agomez

10/06/2017, 8:02 PM
if you are declaring fields in the constructor you should use @field:Transient
if you use just @Transient you are annotating the parameter
t

thatadamedwards

10/06/2017, 8:08 PM
👍
v

villela

10/06/2017, 8:19 PM
@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

agomez

10/06/2017, 8:31 PM
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
10 Views