Open raderio opened 4 years ago
Thanks. It'll be good to have it.
This is relevant to what I'm working on right now.
@raderio - do you see this as independent of the serialization library being used? I'm working on a project using ktor and Jackson, but this would seem to apply to kotlinx.serialization, GSON, and presumably other libraries.
@lyndsysimon It will be nice to have a tool which works with different libraries, yes. At the moment I am looking to be possible to have this feature for database data retrieval.
Hi Team, I am just wondering; what's wrong with simply Utilizing DTO objects like so?
fun projectsWhere(condition: ColumnDeclaring<Boolean>): List<ProjectDTO> {
return db
.from(Projects)
.innerJoin(Locations, on = Projects.locationId eq Locations.id)
.innerJoin(Companies, on = Projects.companyId eq Companies.id)
.innerJoin(Estimators, on = Projects.estimatorId eq Estimators.id)
.select(
Projects.id,
Projects.name,
Locations.address,
Projects.status,
Projects.date,
Companies.name,
Estimators.name
)
.where(condition)
.map { row ->
ProjectDTO(
id = row[Projects.id],
title = row[Projects.name].orEmpty(),
address = row[Locations.address].orEmpty(),
company = row[Companies.name].orEmpty(),
estimator = row[Estimators.name].orEmpty(),
client = "",
status = row[Projects.status].orEmpty(),
date = row[Projects.date]
)
}
}
It's verbose, but flexible at the same time. What kind of a DTO mapping would bring such flexibility to the table?
As a reference, spring jdbc template provides a BeanPropertyRowMapper class as a convenience. Is this the kind of thing we are looking for in KTORM?
Thanks! Great framework, btw!
@lyndsysimon @raderio any new thoughts or directions on this topic?f Thanks
遇到一样的问题, 写起来好痛苦, 有没有解决方案啊现在
This will reduce the boilerplate code that can be deducted from table schema.
@Introspected
is needed to generate the projection on compile time.https://www.jooq.org/doc/3.12/manual/sql-execution/fetching/pojos/ https://micronaut-projects.github.io/micronaut-data/latest/guide/#dto