Sunday, 15 February 2015

spring - Numbers in kotlin is not serializable -



spring - Numbers in kotlin is not serializable -

i found numbers in kotlin not serializable.

first problem

device.kt:

package test.domain import javax.persistence.* entity public class device { public id generatedvalue var id: long = -1 public var name: string = "" ... }

devicerestrepository.kt:

package test.domain import org.springframework.data.repository.pagingandsortingrepository import org.springframework.data.repository.query.param import org.springframework.data.rest.core.annotation.repositoryrestresource repositoryrestresource(collectionresourcerel = "device", path = "device") public trait devicerestrepository : pagingandsortingrepository<device, long?> { public fun findbyname(param("name") name: string): list<device> }

i error when seek compile code, because kotlin.long not serializable:

error:(14, 72) kotlin: type argument not within bounds: should subtype of 'java.io.serializable?'

second problem

i same error when seek utilize java.lang.long:

devicerestrepository.kt:

package test.domain import org.springframework.data.repository.pagingandsortingrepository import org.springframework.data.repository.query.param import org.springframework.data.rest.core.annotation.repositoryrestresource repositoryrestresource(collectionresourcerel = "device", path = "device") public trait devicerestrepository : pagingandsortingrepository<device, java.lang.long?> { public fun findbyname(param("name") name: string): list<device> }

warning:(14, 72) kotlin: class shouldn't used in kotlin. utilize kotlin.long instead.

error:(14, 72) kotlin: type argument not within bounds: should subtype of 'java.io.serializable?'

as-of kotlin 1.0 beta 1 primitive types serializable:

int serializable

now type int , other basic types serializable on jvm. should help many frameworks.

from: http://blog.jetbrains.com/kotlin/2015/10/kotlin-1-0-beta-candidate-is-out/

therefore no longer have issues.

spring serialization kotlin spring-jpa

No comments:

Post a Comment