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
  • c

    cedric

    03/19/2019, 3:35 AM
    Is there an easy way to retrieve the primary key of an
    insert
    (in the case where it's auto increment, obviously, otherwise I already have it)
    s
    t
    • 3
    • 3
  • a

    avolkmann

    03/20/2019, 10:26 AM
    Can we somehow replicate the behavior of Spring @Transactional in tests? So that the transaction will be rolled back after each test
    z
    • 2
    • 2
  • a

    arturo

    03/22/2019, 3:06 PM
    I didn't get with the solution but I've solved using
    Table()
    instead of
    LongIdTable()
    and not using
    EntityID
    at all
    t
    • 2
    • 1
  • f

    Farzad

    04/02/2019, 1:50 PM
    Hi, is there a way to select from multiple tables using DSL without joining them? For example:
    select *
    from Orders o,
         Customers c
    where o.customerId = c.id
      and c.id = 1234;
    c
    h
    t
    • 4
    • 10
  • f

    Farzad

    04/02/2019, 3:46 PM
    Another question- how to run a stored procedure using Exposed?
    t
    • 2
    • 1
  • d

    Dennis Schröder

    04/04/2019, 8:43 AM
    I set up a many-to-many relationship just like they descriped it in the documentation (https://github.com/JetBrains/Exposed/wiki/DAO#many-to-many-reference) But when I call
    Entity.getAll()
    I still get an
    No transaction in context.
    Error! I created each entity in an own transaction. Like described in the documentation! Any hints where to look at?
    a
    t
    • 3
    • 24
  • a

    Antanas A.

    04/09/2019, 11:02 AM
    Hello, are there any plans to deprecate and remove singletons/statics from a library? Now it's complicated to use it in asynchronous environment (coroutines, multi-thread), and not sure if it's compatible with ktor
    t
    • 2
    • 36
  • n

    Nezteb

    04/18/2019, 10:48 PM
    Does Exposed count as an ORM? Or just a SQL generator?
    a
    t
    • 3
    • 3
  • k

    Kevin Schmeichel

    04/24/2019, 6:49 PM
    -.kt
    t
    • 2
    • 3
  • p

    pindab0ter

    04/26/2019, 11:49 AM
    I’m using DAO classes and a
    via
    for a many to many reference. How do I set up the columns so that it cascades a deletion of either table?
    t
    • 2
    • 2
  • t

    tjohnn

    04/27/2019, 8:24 AM
    Something like
    select users.*, detail.address as location from users innerjoin detail on users.id = deail.user_id
    ?
    t
    • 2
    • 2
  • b

    bitkid

    04/28/2019, 10:50 AM
    hey guys! i am trying exposed for the first time and i have question. are you following a certain pattern when converting DAOs to immutable entity objects? i have a PlayerDAO and atm i do
    PlayerDAO.find { Players.email eq "someEmail" }.map { it.toPlayer() }
    . is that a sane approach just adding a method to the DAO which does the conversion?
    t
    • 2
    • 3
  • j

    JohnV

    04/28/2019, 8:00 PM
    This piece of code current errors
    var blocks by Block referrersOn Blocks.articleId
    t
    • 2
    • 5
  • m

    Michal Landsman

    04/30/2019, 9:06 PM
    3. Is possible to force flush (save) of changed entity?
    t
    • 2
    • 1
  • b

    bitkid

    05/13/2019, 9:27 AM
    suspend fun <T> dbTransaction(database: Database, block: () -> T): T = withContext(Dispatchers.IO) { transaction(database) { block() } }
    j
    • 2
    • 1
  • t

    tapac

    05/14/2019, 11:17 AM
    Exposed updated to 0.13.7. Full change log is here > https://github.com/JetBrains/Exposed/blob/master/ChangeLog.md#0137
    🎊 1
    🎉 2
    s
    • 2
    • 1
  • m

    Mihael

    05/14/2019, 4:32 PM
    [qtp1676605578-16] INFO Exposed - Preparing create tables statements took 1ms
    [qtp1676605578-16] INFO Exposed - Executing create tables statements took 3ms
    [qtp1676605578-16] INFO Exposed - Extracting table columns took 35ms
    [qtp1676605578-16] INFO Exposed - Extracting column constraints took 3ms
    [qtp1676605578-16] INFO Exposed - Preparing alter table statements took 38ms
    [qtp1676605578-16] INFO Exposed - Executing alter table statements took 1ms
    [qtp1676605578-16] INFO Exposed - Checking mapping consistence took 10ms
    t
    • 2
    • 7
  • j

    Jonathan Mew

    05/15/2019, 10:55 AM
    Is there a way to install a mock TransactionManager which generates no-op Transactions for component tests?
    s
    • 2
    • 15
  • p

    pindab0ter

    05/15/2019, 11:50 AM
    I’m using the DAO and I have an object with a one-to-many relationship. How can I load the list when I load that object? And if that’s not possible, when is it better to do more things within the transaction context or to open/close multiple transactions within short succession of each other?
    t
    • 2
    • 13
  • n

    Nezteb

    05/15/2019, 3:47 PM
    Are there any decent examples of using
    QueryBuilder
    to get plain SQL statements that can be executed? It’s mentioned in the FAQ, but no where else in any documentation that I can find: https://github.com/JetBrains/Exposed/wiki/FAQ#q-how-to-get-a-plain-sql-query-which-will-be-executed
    s
    • 2
    • 1
  • k

    Kevin Schmeichel

    05/16/2019, 9:22 PM
    I'm slowing figuring out how to do various things that aren't covered in the docs, and wouldn't mind contributing some examples that would probably help others out...
    t
    • 2
    • 12
  • k

    Kevin Schmeichel

    05/17/2019, 12:22 AM
    Can anyone provide an example of using the
    match
    operator
    IN NATURAL LANGUAGE MODE
    ?
    t
    • 2
    • 2
  • m

    Mihael

    05/20/2019, 6:31 PM
    Sessions.select { Sessions.lastUpdated greaterEq DateTime.now().minusSeconds(5).millis }
    Is this the best way of getting current time - 5 seconds with exposed?
    t
    • 2
    • 5
  • m

    Mihael

    05/25/2019, 8:29 PM
    sql
    ```SELECT A.script_name, A.count, (A.count * 100) / totalCount AS percentage, totalCount
    FROM (SELECT script_name, COUNT(*) AS count FROM sessions WHERE client_username = "Miha" GROUP BY script_name) AS A
             INNER JOIN (SELECT COUNT(*) AS totalCount FROM sessions WHERE client_username = "Miha") AS B
    GROUP BY A.script_name
    ``` Can anyone help me write this in Exposed kotlin? I’ve tried using aliases but was never able to select totalCount from a subquery or the main query.
    t
    • 2
    • 2
  • a

    APXEOLOG

    05/28/2019, 6:43 AM
    How do i get max id from the table with exposed?
    t
    • 2
    • 1
  • p

    pindab0ter

    06/06/2019, 2:50 PM
    I’m trying to get ON_DELETE CASCADE working with SQLite. I’ve set up the foreign keys properly, but when deleting the parent, the children stay. I’ve read that SQLite defaults to
    PRAGMA foreign_keys = OFF;
    . I’ve tried setting that using:
    transaction {
        exec("PRAGMA foreign_keys = ON;")
    }
    But still no luck. Any ideas?
    • 1
    • 2
  • v

    Viet Hoang

    06/07/2019, 8:38 AM
    Is there anyway to optimize performance for query with multiple join clauses like this one ?
    Table1.leftJoin(otherTable = Table2, onColumn = { Table1.id }, otherColumn = { Table2.table1Id })
          .leftJoin(otherTable = Table3, onColumn = { Table1.table3Id }, otherColumn = { Table3.id })
          .join(otherTable = Table4, joinType = JoinType.LEFT, additionalConstraint = { (Table1.table5Id eq Table4.table5Id) and (Table1.table3Id eq Table4.table3Id) })
          .leftJoin(otherTable = Table5, onColumn = { Table1.table5Id }, otherColumn = { Table5.id })
          .leftJoin(otherTable = Table6, onColumn = { Table1.table5Id }, otherColumn = { Table6.table5Id })
          .leftJoin(otherTable = Table7, onColumn = { Table3.table7Id }, otherColumn = { Table7.id })
          .leftJoin(otherTable = Table8, onColumn = { Table7.table8Id }, otherColumn = { Table8.id })
          .leftJoin(otherTable = Table9, onColumn = { Table5.table9Id }, otherColumn = { Table9.id] })
          .leftJoin(otherTable = Table10, onColumn = { Table2.table10Id }, otherColumn = { Table10.id })
          .leftJoin(otherTable = Table11, onColumn = { Table2.table11Id }, otherColumn = { Table11.id })
          .leftJoin(otherTable = Table12, onColumn = { Table2.table12Id }, otherColumn = { Table12.id })
          .select {
              println("JOIN: " + (System.currentTimeMillis() - start)/1000)
              start =  System.currentTimeMillis()
              Table1.id inList ids 
          }
          .map {
              println("EXECUTE: " + (System.currentTimeMillis() - start)/1000)
              it.toMasterData()
          }
    It took roughly 3 seconds just for generating query when executed in my local environment.
    t
    • 2
    • 3
  • r

    rapho

    06/10/2019, 3:20 PM
    I have a tableA with two references, how can I query this table like:
    TableA.selectAll().where(TableA.ref1 = object1 and TableA.ref2= object2)
    t
    • 2
    • 8
  • n

    Nikky

    06/11/2019, 6:13 PM
    message has been deleted
    t
    • 2
    • 1
  • m

    Mihael

    06/13/2019, 12:50 PM
    SELECT DISTINCT TABLE_NAME 
        FROM INFORMATION_SCHEMA.COLUMNS
        WHERE COLUMN_NAME IN ('SessionId')
            AND TABLE_SCHEMA='YourDatabase';
    t
    • 2
    • 2
Powered by Linen
Title
m

Mihael

06/13/2019, 12:50 PM
SELECT DISTINCT TABLE_NAME 
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE COLUMN_NAME IN ('SessionId')
        AND TABLE_SCHEMA='YourDatabase';
t

tapac

06/13/2019, 5:19 PM
val result = ColumnsTable.
     slice(ColumnsTable.tableName).
     select { 
         ColumnsTable,columnName inList listOf("SessionId") and 
         ( ColumnsTable.tableSchema eq "YourDatabase"}.
      withDistinct().map {             it[ColumnsTable.tableName]
  }
m

Mihael

06/13/2019, 11:13 PM
Thank you
View count: 2