How can I flatten a nested reference?
See original GitHub issueLets say we have the normal Department entity, but we want the Employee entity to only show the department name, not the fully department object, e.g.:
interface Employee : Entity<Employee> {
val id: Int?
var name: String
...
var departmentName: String
}
How would we define our bindings to accommodate this without storing the department name on the employee table?
object Employees : Table<Employee>("t_employee") {
val id by int("id").primaryKey().bindTo { it.id }
val name by varchar("name").bindTo { it.name }
...
val departmentId by int("department_id").references(Departments) { /* somehow map this to deptName*/ }
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
How to flatten nested references into a simple target?
I have to map between a table specific POJO (flat structure) and a Domain object with nested objects.
Read more >Flattening Nested Collections in Java | Baeldung
In order to flatten this nested collection into a list of strings, we can use forEach together with a Java 8 method reference:...
Read more >Spark SQL - Flatten Nested Struct Column
In Spark SQL, flatten nested struct column (convert struct to columns) of a DataFrame is simple for one level of the hierarchy and...
Read more >Flattening nested arrays - Amazon Athena
To flatten a nested array's elements into a single array of values, use the flatten function. This query returns a row for each...
Read more >Convert nested JSON to a flattened DataFrame - Microsoft Learn
Use $"column.*" and explode methods to flatten the struct and array types before displaying the flattened DataFrame. Scala
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In this case, I’d prefer creating a DTO class and returning that instead, which is a general way as far as I know:
Also this will be solved by https://github.com/vincentlauvlwj/Ktorm/issues/100