Is thr any way to get json data from mysql like f...
# ktor
m
Is thr any way to get json data from mysql like for varchar we do it like this
Copy code
val meterId = varchar("meter_id")
i have a field in mysql db with json data type which is data in following way..
Copy code
"[129691049, 129691048, 129691041, 129690909, 129690240]"
in spring boot it is handled like this
Copy code
@Type(type = "json")
@Column(name = "story_set", columnDefinition = "json")
private Set<Integer> storyIdSet;
what i can't figure out is to write its ktor equivalent
got the solution https://www.ktorm.org/api-docs/org.ktorm.jackson/index.html need to include
Copy code
implementation("org.ktorm:ktorm-jackson:${ktorm_version}")
Copy code
val storyIdSet = json<List<Int>>("story_set")
then can be converted to Set<Int> like
Copy code
val storyIdSet: Set<Int> = it[UserHistoryEntity.storyIdSet]?.toSet() ?: emptySet()
a
Ktor is an http client/server library only. Its responsibility ends as soon as you're out of the API layer of your application. You were most likely using the
spring-data-jpa
module of Spring to get database access through Hibernate. The good news is that you're free to continue using Hibernate with Ktor; it might just take some additional effort to integrate it, because you don't have the whole framework aspect of Spring to do it for you. Ktorm is an excellent solution, but it's not actually related to Ktor at all; just an unfortunate name collision. I can also suggest Exposed, which is also by JetBrains.
m
Thanks @Andrew O'Hara , this is very informative I am new to ktor ..will explore around these too..