zt
01/15/2023, 4:59 AMGuild
object that has a MarkovConfig
Toshihiro Nakamura
01/15/2023, 5:20 AMdave08
01/15/2023, 1:05 PMdave08
01/15/2023, 1:07 PMdave08
01/15/2023, 1:07 PMzt
01/15/2023, 6:31 PMToshihiro Nakamura
01/22/2023, 6:28 AMdave08
01/22/2023, 10:23 AMdave08
01/22/2023, 10:33 AMstore.oneToMany(thisSide, thatSide)[this]
...?Toshihiro Nakamura
01/22/2023, 12:45 PMwhy the thisSide and thatSide can’t be deduced by the annotations?This is because there can be multiple EntityMetamodel instances for a single entity class. For example, you can create a new metamodel from an existing one at runtime.
val r: EntityMetamodel<Employee, Int, _Employee> = Meta.employee.clone(table = "RETIRED_EMPLOYEE")
However, it may be possible to make it unnecessary to specify the thisSide and thatSide by using default arguments.Toshihiro Nakamura
01/22/2023, 12:46 PMIs there a big run time cost each time one callsI don’t think so, but we would consider caching the results....?store.oneToMany(thisSide, thatSide)[this]
dave08
01/22/2023, 12:47 PMEntityStore
generates the map each time, or is it just casted to the result?dave08
01/22/2023, 12:50 PMdave08
01/22/2023, 12:55 PMinclude(...)
query and then checked for/accessed by the generated field, which would add some cohesion to Komapper (but for those using annotations straight in their entities, there's that cohesion anyways...) and then we wouldn't even need that entitystore parameter in those generated functions and there wouldn't be the need to pass down an EntityStore everywhere, it would be saved in the aggregate root.Toshihiro Nakamura
01/22/2023, 1:29 PMTheCurrently the EntityStore generates the map each time. We will change the behavior to cache it in the EntityStore.generates the map each time, or is it just casted to the result?EntityStore
I was also thinking over another little idea... for aggregate rootsInteresting. Can you show me the concept code?
dave08
01/22/2023, 1:55 PMinterface EntityStoreContainer {
var store: EntityStore?
// perhaps other things needed to help here?
....
}
@KomapperEntity
data class Customer(
...
val id: Int,
...) : EntityStoreContainer {
override var store: EntityStore? = null
}
// Maybe there could be better error handling here...
val Customer.addresses: Set<Address>? get() = store?.oneToMany(...)
Toshihiro Nakamura
01/22/2023, 2:26 PMstore.withContext {
for (department in store[Meta.department])) {
// use the generated extension function
val employees = department.employees()
for (employee in employees) {
// use the generated extension function
val address = employee.address()
println("department=${department.departmentName}, employee=${employee.employeeName}, address=${address?.street}")
}
}
}
dave08
01/22/2023, 2:31 PMEntityStore
along with any results... which is a bit messy... I tried to avoid that in MY code in the current implementation by adding an extra property on my root aggregate entity with @KomapperIgnore
and just adding the results of what I got from the EntityStore
into in in the repository layer... then my return type doesn't involve anything Komapper...
My point is finding a way to have the least amount of overhead and boilerplate code to work with all the extra data retreived.dave08
01/22/2023, 2:35 PMstore.oneToOne(a, ia).map { it.key.copy(myProp = it.value?.myProp) }
dave08
01/22/2023, 2:35 PMdave08
01/22/2023, 2:36 PMdave08
01/22/2023, 2:40 PMToshihiro Nakamura
01/28/2023, 8:20 AMdave08
01/29/2023, 10:36 AMdave08
01/29/2023, 10:37 AMdave08
01/29/2023, 10:49 AMalternateType
, now I just commented on pull 859 too... thanks again!