Mahesh Bhatt

03/29/2023, 8:20 PM
Is thr any way to get json data from mysql like for varchar we do it like this
val meterId = varchar("meter_id")
i have a field in mysql db with json data type which is data in following way..
"[129691049, 129691048, 129691041, 129690909, 129690240]"
in spring boot it is handled like this
@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 need to include
val storyIdSet = json<List<Int>>("story_set")
then can be converted to Set<Int> like
val storyIdSet: Set<Int> = it[UserHistoryEntity.storyIdSet]?.toSet() ?: emptySet()

Andrew O'Hara

03/29/2023, 9:32 PM
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
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.

Mahesh Bhatt

03/29/2023, 9:35 PM
Thanks @Andrew O'Hara , this is very informative I am new to ktor ..will explore around these too..