https://kotlinlang.org logo
Join the conversationJoin Slack
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
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
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
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 Linen
exposed
  • v

    Valentin Rouault

    10/26/2018, 4:58 PM
    I now switched to use the DAO for interaction with TornadoFX, because it seems to work while writing. But when I execute the program, I get an IAE: Parameter specified as non-null is null: method org.jetbrains.exposed.dao.EntityClass.wrap, parameter id. But in the docs there is nothing in the examples about having to use an Id apart from the definition of the class. And in the line above I access the database table with the DSL and there it works, so the database isn't empty.
    println("DSL: ${Kreuzungen.selectAll().toList().get(0)}")
    println("Element 1: ${Kreuzung.all().toList().get(0)}")
    a
    • 2
    • 4
  • c

    christophsturm

    10/26/2018, 9:55 PM
    would it be easy to build another dao layer above exposed that uses immutable data classes without inheritance?
    t
    • 2
    • 2
  • t

    tapac

    10/30/2018, 12:10 PM
    Minor update for Exposed (0.11.2): - Built with Kotlin 1.3.0 - Fixed bug that call for createMissingTablesAndColumns could lead to exception while trying to add an index which already exists in db (MySQL only problem)
    👍 3
    d
    • 2
    • 3
  • s

    spand

    11/06/2018, 10:35 AM
    Looking at
    InsertStatement.generatedKey
    . Is there any particular usecase that isnt better handled by
    get()
    ? With
    get()
    you get the correct type, while with
    generatedKey
    you need to
    toInt()
    it or similar. Asking as I would prefer to see it removed since I see some bad usages of it in our codebase.
    t
    • 2
    • 2
  • j

    jeggy

    11/06/2018, 3:27 PM
    How does the batchInsert actually work? I'm trying to insert 50.000 rows at once, and it takes way to long.
    t
    • 2
    • 2
  • m

    Miclebrick

    11/08/2018, 3:06 AM
    Howdy, I'm having issues with database calls freezing on socketRead0, I got a
    SHOW PROCESSLIST
    &
    SHOW ENGINE INNODB STATUS
    output via CLI this time: https://gist.github.com/Miclebrick/8622e4542a7f246bb1f3a8dcda951ba7 Can anyone help me out?
    t
    • 2
    • 22
  • a

    Allan Wang

    11/08/2018, 6:04 PM
    Has anyone attempted to create some sort of listener with Exposed? Is the only way of doing so to manually send a broadcast each time an update method in our DAO/DSL executes and finishes?
    t
    • 2
    • 1
  • j

    jeggy

    11/09/2018, 6:09 PM
    I'm trying to create a auto batch inserter. I have a map of
    <T: Any> Map<Column<out T?>, T>
    . My only problem is, how can I convert the
    out T?
    into
    T?
    ?
    t
    • 2
    • 3
  • a

    Allan Wang

    11/10/2018, 6:15 AM
    Is there a short form for insert and get? Where I want to get not just a column but the entire row
    t
    • 2
    • 4
  • a

    Allan Wang

    11/10/2018, 7:27 AM
    Is there a way to do a join with a max condition? Like this example: https://stackoverflow.com/a/725164/4407321 A potential alternative if not is for me to store a reference id in the left table, but I'd like to avoid that
    t
    • 2
    • 4
  • e

    erica

    11/12/2018, 5:14 PM
    is there any way to do something like
    varchar(MAX)
    for table definition? I need to insert more than 8000 chars. I’m using DSL and SQL.
    c
    t
    • 3
    • 6
  • s

    Sergio Casero

    11/14/2018, 4:16 PM
    Hello guys! Just small and noob question, how can I retrieve the "sum" value in the result row when using groupBy?
    o
    t
    • 3
    • 8
  • m

    Miclebrick

    11/20/2018, 4:06 PM
    I think the freezing issue I was having is due to concurrent inserts, https://stackoverflow.com/questions/32498437/deadlock-in-mysql-due-to-insert-by-multiple-threads since apparently that's a thing. One user on SO said they solved it by trying again after a thread.sleep, how would I do that with Exposed?
    t
    • 2
    • 2
  • s

    Sergio Casero

    11/21/2018, 5:21 PM
    Hi guys! one question, I'm trying to connect exposed with my database on Google Cloud, I can do that "without any problems". But seems to be too slow, Could the issue be that I'm not using SSL? I get this warning every time I perform a query:
    WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
    t
    • 2
    • 3
  • a

    Alice

    11/26/2018, 4:05 PM
    Hey guys, I'm trying to recreate this app I wrote with spring using Ktor and Exposed, and I'm following the tutorial for DAOs on the github, but I'm a little confused. My situation simplified is basically, I have a User model that has an ID and a reference to an Image model, I want to be able to do User.images and Image.user. So my user (simplified) is like
    class User(id: EntityID<Long>) : LongEntity(id) {
        var images by Image via UserImages
    
        companion object : LongEntityClass<User>(Users)
    }
    My image simplified is like
    class Image(id: EntityID<Long>) : LongEntity(id) {
        val user by User referencedOn Images.user
    
        companion object : LongEntityClass<Image>(Images)
    }
    And my tables are as follows
    object Images : LongIdTable() {
        val user = reference("user", Users)
    }
    
    
    object Users : LongIdTable() {
    // Do I need to do something to establish a relationship to images here?
    }
    
    object UserImages : Table() {
        val user = reference("user", Users).primaryKey(0)
        val image = reference("image", Images).primaryKey(1)
    }
    I've been following the tutorial on the wiki, and I was fine with everything I think until I started trying to establish this relationship. I hope this isn't too much of a noob question, I just decided to try Kotlin yesterday after people scala-shaming me for months 😜.
    t
    • 2
    • 12
  • m

    Marcin Wisniowski

    11/30/2018, 3:08 PM
    Ok it seems I can do
    !User.find { Users.login eq login }.empty()
    , still not sure if this is the proper way
    a
    • 2
    • 2
  • o

    oshai

    12/02/2018, 2:16 PM
    General question - are all executed queries in exposed use
    PreparedStatement
    ?
    t
    • 2
    • 2
  • j

    Jorge R

    12/07/2018, 3:38 PM
    hi guys, I've a question. Im a bit noob on exposed, I can see 'deleteWhere' returns Int. How can I know the result of the operation? 1(or itemId)-> deleted, 0-> not found?
    t
    f
    • 3
    • 6
  • y

    yen

    12/10/2018, 8:57 AM
    Does anyone know how to do the equivalent of the following in Exposed?
    SELECT * 
    FROM my_table 
    WHERE (col1, col2) IN ((1, 'apple'), (2, 'banana'), (3, 'cat'));
    t
    • 2
    • 1
  • r

    reik.schatz

    12/12/2018, 3:29 PM
    Foo.insert {
        it[name] = foo.name
        it[query] = foo.query
        it[description] = foo.description
        it[status] = foo.status
    } 
    
    Foo.update (where = { Foo.id.eq(fooId) } ) {
        it[name] = foo.name
        it[query] = foo.query
        it[description] = foo.description
        it[status] = foo.status
    }
    t
    • 2
    • 2
  • t

    tKw

    12/13/2018, 6:04 PM
    I asked this in #general and #mockk as well, but wanted to check with this channel too. Has anyone had luck using MockK for mocking Exposed, especially for transactions against models, and verifying that they are being called as expected?
    t
    • 2
    • 1
  • d

    Dave

    12/17/2018, 9:25 AM
    Is using Exposed DDD(Domain driven design) bad style ? I just want to know that 🙂
    t
    • 2
    • 3
  • r

    rrader

    12/19/2018, 10:15 AM
    What Kotlin feature is used for
    object Users : Table() {
        val id = varchar("id", 10).primaryKey() // Column<String>
        val name = varchar("name", length = 50) // Column<String>
        val cityId = (integer("city_id") references Cities.id).nullable() // Column<Int?>
    }
    Users.insert {
                it[id] = "andrey"
                it[name] = "Andrey"
                it[cityId] = saintPetersburgId
            }
    how compiler know that
    it[id]
    is valid and for example
    it[title]
    is not valid?
    a
    • 2
    • 1
  • r

    rrader

    12/24/2018, 7:49 AM
    @tapac @orangy why JB team has 2 similar projects? Why not to develop one solution? https://github.com/JetBrains/Exposed https://github.com/orangy/squash
    t
    • 2
    • 2
  • r

    rrader

    12/30/2018, 7:51 PM
    Does transaction support isolation levels?
    t
    t
    • 3
    • 6
  • b

    bjonnh

    01/02/2019, 6:43 PM
    would that make sense to add ilike : infix fun<T:String?> ExpressionWithColumnType<T>.ilike(pattern: String): Op<Boolean> = ILikeOp(this, QueryParameter(pattern, columnType)) class ILikeOp(expr1: Expression<*>, expr2: Expression<*>) : ComparisonOp(expr1, expr2, "ILIKE")
    t
    • 2
    • 3
  • b

    bjonnh

    01/03/2019, 7:58 PM
    is there a better way to write that:
    kotlin
    fun getCitation(code: String, offset: Int = 0): Citation? {
            var result: Citation? = null
            transaction(db) {
                result = Citation.wrapRows(Citations
                    .select { Citations.code eq code }.limit(1)).toList().getOrNull(0)
            }
            return result
        }
    t
    t
    • 3
    • 2
  • t

    Torbilicious

    01/08/2019, 1:38 PM
    Hi! I am trying to insert sample data into my mysql database. I am using the following code:
    SomeTable.batchInsert((0 until 1_000).toList()) { number ->
        this[SomeTable.type] = "some-type"
        this[SomeTable.data] = """{"foo":"$number"}"""
    }
    but for some reason exposed creates 1000 statements for this instead of one batch statement. Is this the intended behaviour, or am i missing something?
    t
    • 2
    • 1
  • s

    SackCastellon

    01/09/2019, 10:12 AM
    This seems to happen in all database types, not only in MySQL. I think this should be fixed.
    t
    • 2
    • 1
  • j

    jonathan

    01/10/2019, 5:42 PM
    Hi all, I was wondering if there was a way to do something like this in Exposed:
    UPDATE Orders SET Quantity = Quantity + 1 WHERE ...
    (I'm currently just doing it with a raw SQL query)
    t
    • 2
    • 2
Powered by Linen
Title
j

jonathan

01/10/2019, 5:42 PM
Hi all, I was wondering if there was a way to do something like this in Exposed:
UPDATE Orders SET Quantity = Quantity + 1 WHERE ...
(I'm currently just doing it with a raw SQL query)
t

tapac

01/10/2019, 9:40 PM
https://github.com/JetBrains/Exposed/wiki/DSL#update
j

jonathan

01/10/2019, 9:43 PM
Ah rip, missed that. Thank you!
View count: 8