https://kotlinlang.org logo
Docs
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
  • t

    tapac

    06/14/2018, 10:48 AM
    Exposed 0.10.3 was released (https://bintray.com/kotlin/exposed/exposed/0.10.3) Features: 1. Floating point columns 2. Check constraint functionallity (kudos to @SackCastellon) 3. Possibility to provide custom names for contraints and indexes (thanks to @mduesterhoeft) 4. Added support to delete with limit and offset (thanks @Yuku Kotani for initial PR) 5. Full SQL will be now logged on any SQLException (#288 [Suggestion] Log the SQL query when an exception is thrown) 6. Postgres support for ignore + replace 7. H2 support for INSERT IGNORE for new H2 version 8. Statement interceptors now allow triggering on before commit and rollback 9. Database ENUM types supported (read more [here](https://github.com/JetBrains/Exposed/wiki/DataTypes#how-to-use-database-enum-types)) Bug fixes: 1. #279 'SELECT MAX(datetime)' throws ClassCastException 2. #289 UUID's are not shown in logs 3. #284 Postgres, DSL Approach: primary key with custom names beside `...
    👍 1
    s
    • 2
    • 4
  • s

    samir

    06/20/2018, 9:51 AM
    @tapac Next release?
    t
    • 2
    • 2
  • m

    mkporwit

    06/22/2018, 12:42 AM
    I see that there’s an
    onDelete = ReferenceOption.CASCADE
    for foreign key constraints. Is there support for something like MySQL’s
    ON UPDATE CASCADE
    ?
    t
    • 2
    • 2
  • f

    frellan

    06/22/2018, 9:43 PM
    Hello guys! I am planning on moving to this library for persistence, planning to use the DSL since I want more control of my sqls. Just a general question really, how do one handle nested relations with a dsl approach? One may want to have relations on the domain model but don’t load them all the time, so they would be null, so you would end up with a lot of stuff that is null, which is not nice. How do you guys do this? Remove the relations from the domain model and just keep the relations in the database, i.e dont do
    entity.otherEntites
    but rather
    DB.getOtherEntetiesFor(entity)
    or similar. How do you do this, need tips 🙂
    t
    • 2
    • 3
  • m

    mkporwit

    07/02/2018, 7:03 PM
    That’s fine, but there’s no way for me to specify utf8mb4 as either the
    characterEncoding
    or the
    characterSetResults
    . Exposed blows up with an
    ExceptionInInitializedError
    . If
    characterSetResults=utf8mb4
    is specified on the connect string, the underlying exception is
    java.sql.SQLException: Can't map utf8mb4 given for characterSetResults to a supported MySQL encoding.
    , and if I do
    characterEncoding=utf8mb4
    , it is
    java.sql.SQLException: Unsupported character encoding 'utf8mb4'
    .
    t
    • 2
    • 1
  • s

    Sherub Thakur

    07/04/2018, 8:55 AM
    Hi there can I catch specific exceptions instead of just a blanket exception (
    ExposedSQLException
    )? Right now I have to do string processing on the message given by the exception to perform any task. Something like
    RefrentialIntegrityConstraintViolationException
    or
    UniqueConstraintViolationException
    etc would be really helpful.
    t
    • 2
    • 1
  • b

    bubakovsky

    07/08/2018, 5:46 PM
    Hi! I'm a bit new to ORM and DB connection in app. I've switched from DAO to DSL way because of better separation between data and code (multitier architecture). Question - what would you recommend to access values from referenced columns (like in DAO way)? I'm talking about using
    data class
    in higher tiers. Only possible way I could come up with is to create
    Map
    for every 1:N relationship, which might be very monstrous in the end. How do you usually deal with that? Thanks for the reply in advance!
    t
    • 2
    • 2
  • m

    mkporwit

    07/17/2018, 5:42 PM
    Any ideas when 0.10.4 will be out, @tapac?
    t
    • 2
    • 2
  • n

    Norg

    07/23/2018, 2:33 PM
    Hi everyone! Can anyone answer, is there nested transactions support?
    t
    o
    • 3
    • 6
  • t

    tapac

    07/28/2018, 12:28 PM
    So first, how the heck does this even work? I can’t seem to figure it out from reading the source.
    inList and other functions declared within SqlExpressionBuilder that’s why you can’t access them out of select {} block, which defined as :
    inline fun FieldSet.select(where: SqlExpressionBuilder.()->Op<Boolean>)
    m
    • 2
    • 1
  • v

    v79

    07/29/2018, 7:37 PM
    Does exposed (DAO) support inheritance of tables? I'm hoping for
    abstract class BaseTable : LongIdTable() {
    val createdOn = datetime("createdOn")
    val lastUpdatedOn = datetime("createdOn")
    }
    
    object Page : BaseTable() {
    val name = varchar("name",255)
    .... *etc*
    • 1
    • 1
  • v

    v79

    08/04/2018, 8:15 AM
    Does anyone else's brain just hurt trying to build relationships in Exposed DAO? When to use
    referrersOn
    , when to use
    referencedOn
    ? What's wrong with
    hasOne
    ,
    hasMany
    ? The DSL syntax is so much cleaner, but isn't really an ORM. Why a class and an object? And why do I only have to set up the relationship between two tables on three of these?
    a
    • 2
    • 2
  • n

    nekoinemo

    08/13/2018, 9:05 AM
    Hi. I just noticed that despite be calling
    batchInsert()
    , requests printed in console are all separate inserts rather than
    INSERT INTO table (col1, col2) VALUES (val11, val12), (val21, val22), (val31, val32)
    . Am i misunderstanding how batch supposed to work in Exposed?
    t
    • 2
    • 3
  • n

    nekoinemo

    08/14/2018, 7:38 PM
    Another question: can i manually abort transaction from within transaction block? Other than to throw exception?
    s
    b
    • 3
    • 4
  • g

    Gerard Downes

    08/15/2018, 1:24 PM
    On_delete_cascade.txt
    t
    • 2
    • 1
  • b

    BorzdeG

    08/21/2018, 2:59 PM
    Tell me how to write such a SQL query?
    SELECT IF(myTableColumn<2 OR myTableColumn>4, TRUE, FALSE) as myColumn FROM myTable;
    t
    • 2
    • 1
  • j

    jonathan

    08/26/2018, 10:57 PM
    How would I write a query like this using Exposed?
    SELECT requested.GroupId, requested.Member, requested.isAdmin, requested.isOwner
      FROM GroupMembers requested, GroupMembers requestor
      WHERE requested.GroupId = 1 AND requested.Member = 1 AND requestor.GroupId = 1 AND requestor.Member = 2
    t
    • 2
    • 2
  • z

    zpearce

    08/29/2018, 11:10 PM
    Is there a way to set the timezone for postgres other than
    -Duser.timezone=UTC
    ?
    t
    • 2
    • 2
  • s

    spand

    09/03/2018, 9:53 AM
    Has support for mysql
    USE INDEX
    been considered ?
    t
    • 2
    • 3
  • z

    zpearce

    09/11/2018, 3:09 PM
    is there any way to begin and commit a transaction in two steps instead of using the
    transaction
    function that takes a lambda?
    t
    • 2
    • 2
  • o

    oshai

    09/11/2018, 7:07 PM
    @tapac - do you think it can be a good idea to wire up exposed to async driver?
    t
    • 2
    • 4
  • b

    barrongineer

    09/19/2018, 8:20 PM
    Can anyone point me in the right direction for using Exposed with TornadoFX? Google isn’t giving me much love. Currently getting:
    Sep 19, 2018 3:54:51 PM tornadofx.DefaultErrorHandler uncaughtException
    SEVERE: Uncaught error
    java.lang.IllegalStateException: No transaction in context.
    m
    • 2
    • 2
  • m

    mkporwit

    09/19/2018, 11:50 PM
    Before I go spelunking deeper into why my code stopped working when I update from
    0.10.4
    to
    0.10.5
    , does anyone here have theories as to why this update would fail? There are no changes in the code, just the version change. The failure is in integration tests that start with a clean database every time. This is on a MySQL instance:
    2018-09-19 16:41:39.502 [io-thread-1] INFO  Exposed - Transaction attempt #0 failed: java.sql.BatchUpdateException: Cannot add or update a child row: a foreign key constraint fails (`authdb`.`Roles`, CONSTRAINT `Roles_ibfk_1` FOREIGN KEY (`orgId`) REFERENCES `Orgs` (`id`) ON DELETE CASCADE ON UPDATE CASCADE). Statement(s): INSERT INTO Roles (name, orgId, permissions) VALUES (?, ?, ?);
    INSERT INTO Roles (name, orgId, permissions) VALUES (?, ?, ?);
    INSERT INTO Roles (name, orgId, permissions) VALUES (?, ?, ?);
    INSERT INTO Roles (name, orgId, permissions) VALUES (?, ?, ?)
    org.jetbrains.exposed.exceptions.ExposedSQLException: java.sql.BatchUpdateException: Cannot add or update a child row: a foreign key constraint fails (`authdb`.`Roles`, CONSTRAINT `Roles_ibfk_1` FOREIGN KEY (`orgId`) REFERENCES `Orgs` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)
    t
    • 2
    • 3
  • h

    Hullaballoonatic

    09/24/2018, 8:59 PM
    How can I get a table object's contains operator to differentiate between parameters corresponding to different fields that are both strings? I'm currently writing out different classes for each string to accomplish this, but if there's an easier way, i'm all ears. e.g.
    operator fun contains(username: String): Boolean = UserEntity.find { self.username eq username }.count() > 0
    operator fun contains(email: Email): Boolean = UserEntity.find { self.email eq email }.count() > 0
    also if there's a more efficient way to write a contains function, i wouldn't be surprised in the slightest
    t
    • 2
    • 2
  • d

    Darren Gaughan

    10/01/2018, 10:16 PM
    I'm getting an 'IllegalStateException - "countOfOtherEntity" is not in record set' error. Is my understanding of this correct? Should I be able to access this value through val countOfOtherEntity = integer("countOfOtherEntity")?
    t
    • 2
    • 1
  • f

    franek

    10/05/2018, 8:34 AM
    Hi, I have table song and table genre. Song can contains more genres. So I want reference genreIds from table genre. How I can reference to array of foreign keys? For single reference is syntax (integer(“genre_id”) references GenreTable.id) it is working but what about more values?. Or I use it bad?
    Reference_to_array_of_foreign_keys.kt
    t
    a
    • 3
    • 3
  • f

    franek

    10/08/2018, 8:18 PM
    Does anyone know how to write something like andWhere if I use many to many reference?
    Untitled.kt
    t
    • 2
    • 8
  • h

    Hamza

    10/21/2018, 12:03 PM
    what is the url for the jdbc driver? im using
    val jdbc = "jdbc:mysql://$user:$pass@$url"
        Database.connect(jdbc, driver)
    with
    com.mysql.cj.jdbc.Driver
    as driver, and url being
    [redacted]:3306/[databaseName]
    t
    • 2
    • 2
  • a

    APXEOLOG

    10/21/2018, 1:28 PM
    I'm new to kotlin, not sure how to do it properly
    h
    • 2
    • 9
  • a

    APXEOLOG

    10/25/2018, 7:15 AM
    Hello guys. Is there any easy way to make
    SELECT ... IN
    but using composite key with 3 fields?
    t
    • 2
    • 5
Powered by Linen
Title
a

APXEOLOG

10/25/2018, 7:15 AM
Hello guys. Is there any easy way to make
SELECT ... IN
but using composite key with 3 fields?
t

tapac

10/25/2018, 10:11 AM
Could you show raw sql as an example of what you want to achieve?
a

APXEOLOG

10/25/2018, 11:13 AM
@tapac
SELECT *
  FROM table_name
 WHERE (key_part_1, key_part_2) IN ( ('B',1), ('C',2) );
I tried to look through the
inList
function of the SQL builder but i'm not that good at kotlin to make something similar for multiple column case
t

tapac

10/25/2018, 11:23 AM
https://github.com/JetBrains/Exposed/issues/373#issuecomment-414123325
a

APXEOLOG

10/25/2018, 1:09 PM
Thanks!
View count: 10