https://kotlinlang.org logo
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
benchmarks
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
confetti
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
lincheck
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by
Title
d

dave08

01/15/2023, 1:41 PM
It might also be nice to generate a list or set of all of the contents of each Meta object in the Meta object. Often one would like to just create or drop all the tables in tests, and manually managing such a list is a bit error prone and extra boilerplate.
t

Toshihiro Nakamura

01/15/2023, 2:39 PM
We had the same discussion here: https://github.com/komapper/komapper/issues/681
d

dave08

01/15/2023, 2:53 PM
I'm not sure if this is a better solution, but I added a comment there: https://github.com/komapper/komapper/issues/681#issuecomment-1383170621
@Toshihiro Nakamura Did you have a chance to see this comment? Maybe making the generated entity meta classes to derive from a sealed class would be simpler, and then it would be easy to retreive all those tables from a particular Meta object...
I bit hard to discuss things in a Github issue, I can summarize concusions thereafterwards @Toshihiro Nakamura... there's no need to add any subclasses to the sealed class in another module... you'd be generating them all in ksp. I won't be adding any in my code. I'm talking about the generated
org.komapper.core.dsl.metamodel.EntityMetamodel
being the subclasses.
t

Toshihiro Nakamura

01/18/2023, 12:49 PM
However, how should the Komapper KSP processor determine the sealed interface name in that case?
d

dave08

01/18/2023, 12:50 PM
According to the
Meta
class name, maybe
Meta1EntityMetaModel
when
Meta1
is used?
Since it only makes sense to have a sealed interface per meta class... since another Meta class denotes another database. So any create or drops would be on ONE meta class's
allTables
t

Toshihiro Nakamura

01/18/2023, 12:57 PM
maybe
Meta1EntityMetaModel
when
Meta1
is used
How about the package name of the sealed interface? We want not to use
org.komapper
.
d

dave08

01/18/2023, 12:58 PM
You don't have to, all you need is a unique
Meta
object name... or to generate a unique name from it and use that in
allTables
.
It could even be OrgKomapperMetaEntityMetaModelBase...
It doesn't have to be exposed outside... but it might be nicer to have something that even users might use... so a short one would be more user friendly.
t

Toshihiro Nakamura

01/18/2023, 1:07 PM
There is still an issue with that approach. If you have two modules that use Komapper, the names of their sealed interfaces will conflict.
d

dave08

01/18/2023, 1:10 PM
How do you handle that for
Meta
objects? I don't think it makes sense that two separate modules should be able to contribute to the same Meta object's tables...?
t

Toshihiro Nakamura

01/18/2023, 1:45 PM
That is a possible use case. We use it in our Komapper integration testing. There is no problem using the same Meta object from two separate modules as long as the entity names do not conflict.
d

dave08

01/18/2023, 1:50 PM
How does one module use the other's entities? You'd need to make a cross dependency for each module to have a complete view of all the tables... I could understand that maybe a subset of tables in one database might be encapsulated into a module that is the only one to use those tables... in that case, which might not be so common, you could technically have an option to enable/disable the generation of
allTables
and the sealed interface altogether, but I don't see this as such a common case...?
Also, even in such a case, one could always create a new Meta object only for that module... so the option could be whether Meta could be used in a cross-module context... then the sealed interface would not be generated...
t

Toshihiro Nakamura

01/21/2023, 10:08 AM
I don’t think using sealed interface is a best idea. I tried to implement it using Service Provider. Let me know what you think. https://github.com/komapper/komapper/pull/857