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

    Animesh Sahu

    11/23/2019, 8:47 AM
    where are CHECK constriant for sqlite connection? https://stackoverflow.com/a/17203007/11377112
    t
    • 2
    • 3
  • v

    vpriscan

    11/24/2019, 1:27 PM
    eg, I want "modified" column to default to "created" column value
    t
    • 2
    • 1
  • r

    Rodrigo Silva

    11/25/2019, 9:41 PM
    Does Exposed have something like Hibernate's "first lvl cache"? The query returns 2 objects (I'm using join) but as they are the same I wanted to discard one.
    t
    • 2
    • 6
  • r

    rikusen0335

    11/26/2019, 11:28 AM
    is there any method like
    Database.disconnect
    s
    t
    • 3
    • 7
  • v

    Vinicius Araujo

    11/26/2019, 5:56 PM
    How can I get
    java.sql.Connection
    from exposed's TransactionManager? I've only found ExposedConnection which doesnt have
    createArrayOf
    function
    t
    • 2
    • 1
  • a

    Animesh Sahu

    11/27/2019, 8:48 AM
    Few questions to ask, 1. How to check if the connection is alive? 2. How to reconnect if the connection is closed (randomly)?
    t
    • 2
    • 1
  • a

    Animesh Sahu

    11/27/2019, 8:49 AM
    ------------------------------------------------------------------------------------ Another question: I am getting when consuming the data (select statement) using forEach()
    Exception in thread "DefaultDispatcher-worker-7 @coroutine#49" org.sqlite.SQLiteException: [SQLITE_BUSY]  The database file is locked (database is locked)
    	at org.sqlite.core.DB.newSQLException(DB.java:941)
    	at org.sqlite.core.DB.newSQLException(DB.java:953)
    	at org.sqlite.core.DB.throwex(DB.java:918)
    	at org.sqlite.core.DB.exec(DB.java:178)
    	at org.sqlite.SQLiteConnection.commit(SQLiteConnection.java:404)
    	at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManager$ThreadLocalTransaction.commit(ThreadLocalTransactionManager.kt:57)
    	at org.jetbrains.exposed.sql.Transaction.commit(Transaction.kt:66)
    	at org.jetbrains.exposed.sql.transactions.experimental.SuspendedKt.commitInAsync(Suspended.kt:103)
    	at org.jetbrains.exposed.sql.transactions.experimental.SuspendedKt.access$commitInAsync(Suspended.kt:1)
    	at org.jetbrains.exposed.sql.transactions.experimental.SuspendedKt$suspendedTransactionAsyncInternal$1.invokeSuspend(Suspended.kt:168)
    	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    	at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:241)
    	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594)
    	at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60)
    	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:740)
    t
    • 2
    • 5
  • r

    rikusen0335

    11/27/2019, 2:20 PM
    Is there an way to set and use member(class?) variavles for db in class method like:
    var db: Database
    
        override fun onEnable() {
            // Enabled message
            server.consoleSender.sendMessage("%sSamplePlugin is now enabled!".format(ChatColor.GREEN))
            server.pluginManager.registerEvents(this, this)
    
            val basePath: Path = Paths.get(System.getProperty("user.dir")).toRealPath()
            val sqliteFile: Path = Paths.get(basePath.toString(), "sample.db")
            print(sqliteFile) // Show the paths
            db = Database.connect("jdbc:sqlite:file:$sqliteFile", "org.sqlite.JDBC")
    
            TransactionManager.manager.defaultIsolationLevel = Connection.TRANSACTION_SERIALIZABLE
        }
    
        override fun onDisable() {
            TransactionManager.closeAndUnregister(db) // Disconnect処理?
        }
    e
    • 2
    • 1
  • n

    Norg

    11/28/2019, 10:53 AM
    can anyone help please? cannot use types
    date
    and
    datetime
    in exposed 18.1 dao. In the following example
    date
    causes the
    Unresolved reference: date
    object TimeSlots : LongIdTable() {
        val slotDate: Column<Date>      = date("slotDate")
        val duration: Column<String>    = varchar("duration", 10)
    t
    • 2
    • 4
  • r

    Rodrigo Silva

    11/29/2019, 2:04 AM
    Using jackson, how do I serialize / deserialize exposed-jodatime?
    t
    • 2
    • 4
  • r

    Roy Nard

    11/29/2019, 9:57 AM
    I am looking at the exposed SQL library.. How do I interact with a table that already exists in the database and was created long before Kotlin? I guess I must declare it but ensure that the properties or schema matches perfectly. Is there anyway to ensure that I match the properties of the in this case, MySQL table ?
    s
    t
    • 3
    • 6
  • a

    Animesh Sahu

    12/01/2019, 3:46 PM
    Somebody have some idea of how to use sqlite3 with exposed using coroutines? I'm tired of the exception of SQLITE_BUSY :(
    t
    • 2
    • 2
  • a

    Animesh Sahu

    12/02/2019, 4:10 PM
    what is difference between
    suspendedTransactionAsync()
    and
    newSuspendedTransaction()
    i know one of them return Deferred and other the direct value. But i see that both of them suspend at the time of call, i.e. if `suspendedTransactionAsync()`suspends at the time of call then what is use of
    await()
    on the deferred? Like
    CoroutineScope.async()
    doesn't suspend at the time of call but rather when
    await()
    is called on that right, so what's difference b/w them(transactions)?
    t
    • 2
    • 10
  • a

    Animesh Sahu

    12/02/2019, 5:00 PM
    So confused of this library due to slow support and no documentation/not even class definition in package 😞
    t
    • 2
    • 2
  • a

    Animesh Sahu

    12/02/2019, 5:01 PM
    I want to get result row of what i am inserting after successful insert how could i do that?
    t
    • 2
    • 2
  • m

    marstran

    12/02/2019, 11:23 PM
    I saw the R2DBC APIs got to 0.8.0 GA today. Are there any plans to integrate that with Exposed? https://r2dbc.io/2019/12/02/r2dbc-0-8-0-goes-ga
    t
    • 2
    • 1
  • b

    Brian Carbone

    12/04/2019, 8:25 PM
    you can't use a fixed length char column?
    t
    • 2
    • 4
  • t

    tapac

    12/10/2019, 7:05 AM
    Just for the information - we use Exposed at production services for more than a 5 years.
    e
    • 2
    • 1
  • t

    Timur Atakishiev

    12/12/2019, 5:12 AM
    Hi all, I got an expression like
    transaction {
        Restaurants.slice(Restaurants.followers.min(),Restaurants.id)
                .selectAll()
                .groupBy(Restaurants.id)
                .first()
    }
    and I have a simple mapper
    private fun toRestaurantUserName(row: ResultRow) = RestaurantUserNameDto(
            id = row[Restaurants.id],
            numberOfFollowers = row[Restaurants.followers.min()]!!
    )
    my question is when I want to fetch Restaurants.followers.min(), should I use
    row[Restaurants.followers.min()]!!
    these one with double !!, or is it better way to write the code?Thank you
    t
    • 2
    • 2
  • t

    tapac

    12/14/2019, 4:03 PM
    Exposed 0.19.3 released with several bug fixes for 0.19.1: https://github.com/JetBrains/Exposed/blob/master/ChangeLog.md#0193
    👍 2
    🎉 4
    e
    • 2
    • 2
  • d

    dmnk_89

    12/17/2019, 9:16 AM
    SomeTable.batchInsert(
    				data = listOf(1,2,3,4),
    				body = {
    					this[SomeTable.someColumn] = it
    				})
    t
    • 2
    • 1
  • t

    Timur Atakishiev

    12/17/2019, 10:19 AM
    I was able to use batch insert for exposed, but when I am adding
    transaction {
                addLogger(StdOutSqlLogger)
                SomeTable.batchInsert(data = listOf(1,2,3,4)) {
                    this[SomeTable.someColumn] = it
                }
    SQL logger shows multiple sql inserts(number of insrets = list.size) Should not it be one insert with multiple values? Or is it StdOutLogger problems?
    s
    t
    • 3
    • 6
  • t

    tapac

    12/27/2019, 1:01 PM
    Exposed 0.20.1 released. Check change log for more information of new features and bug fixes. https://github.com/JetBrains/Exposed/blob/master/ChangeLog.md#0201
    🎉 3
    l
    • 2
    • 1
  • b

    Brian Carbone

    12/30/2019, 6:39 PM
    kotlin
    SELECT * FROM (
      SELECT DISTINCT ON (address_id) *
      FROM purchases 
      WHERE product_id = 1
      ORDER BY address_id, purchased_at DESC
    ) t
    ORDER BY purchased_at DESC
    what is the equivalent of this in exposed?
    t
    t
    • 3
    • 3
  • a

    APXEOLOG

    12/30/2019, 7:38 PM
    Hello guys! I'm migrating from 0.17 to 0.20. I was using jsonb data type from here:
    <https://gist.github.com/quangIO/a623b5caa53c703e252d858f7a806919>
    and i found out that ColumnType seems to be changed
    t
    • 2
    • 1
  • v

    Vinicius Araujo

    01/04/2020, 8:21 PM
    Hey there, is there a way to achieve this composite where clause with exposed?
    WHERE (updated_at, id) <= ('2020-01-04 15:51:38.862000', '79a4f222-69ea-439c-90ba-348d025166ef')
    t
    • 2
    • 6
  • t

    Timur Atakishiev

    01/05/2020, 5:15 PM
    Hi all
    object Users : Table("users") {
        override val primaryKey = PrimaryKey(columns = *arrayOf(Column<Long>(Users, "id", LongColumnType())))
        val id = long("id").autoIncrement()
        val phoneNumber = varchar("phone_number", 20).uniqueIndex()
        val firstName = varchar("first_name", 25).nullable()
        val lastName = varchar("last_name", 30).nullable()
        val password = varchar("password", 150)
    }
    can someone help please, when I overriding primary key as
    override val primaryKey = PrimaryKey(columns = *arrayOf(id))
    IDE says me that I need to initialize the ID field, maybe I am doing something wrong? Or is it other way to declare a Primary key?
    s
    • 2
    • 2
  • p

    paulex

    01/08/2020, 12:18 PM
    override fun modify(item: User): CompletionStage<User> {
        return supplyAsync {
            transaction {
                Users.update({ Users.id eq item.id }) {
                    it[name] = item.name
                    it[gender] = item.gender
                    it[first_name] = item.firstName;
                }
            }
        }.thenApply { return@thenApply item }
    }
    Is there a way to simplify an update transaction on object properties, i feel it is repetitive to keep on writing : it[name] = item.name it[gender] = item.gender ?
    a
    s
    • 3
    • 3
  • t

    Timur Atakishiev

    01/10/2020, 7:55 AM
    hey guys, can not find how to implement batch update in exposed, please help! I am using DSL
    t
    m
    • 3
    • 10
  • c

    Carter

    01/12/2020, 12:53 PM
    Hi. Issue 748 is blocking me from upgrading to the 0.20.x series. I know the code change has been merged to master. Is there a regular release schedule planned? No rush, just trying to figure out planning on my end as I’d like to be able to make the version bump to unblock some other code changes I’d like to make.
    t
    • 2
    • 7
Powered by Linen
Title
c

Carter

01/12/2020, 12:53 PM
Hi. Issue 748 is blocking me from upgrading to the 0.20.x series. I know the code change has been merged to master. Is there a regular release schedule planned? No rush, just trying to figure out planning on my end as I’d like to be able to make the version bump to unblock some other code changes I’d like to make.
t

tapac

01/13/2020, 6:28 AM
Hopefully today or tomorrow.
You may try 0.20.3
c

Carter

01/13/2020, 2:05 PM
Thanks, I just gave it a try. It looks like my issue might be something else. I’m still getting a
java.lang.IllegalStateException: Can't load implementation for DatabaseConnectionAutoRegistration
. If I roll back to 0.17.7 (and make the changes to dependencies and imports for my objects), then it runs just fine. I can try to troubleshoot some more on my end, although I’m not clear what might isolate it further just yet. The initialization is pretty straightforward. I’m just trying to use a SQLite database file. I also tried a h2 database but that didn’t make a difference.
I think I got past the issue. 🎉 Looks like some kind of weird caching in IntelliJ was happening.
🎉 1
So I have some more info on the issue I was seeing. I’m using multiplatform, mostly to force me to avoid JVM only stuff getting hooked deeply into many of my model objects I’m writing although I still run the project on the JVM. exposed is integrated into a library and it has the
core
and
dao
dependencies as
api
, and
sqlite-jdbc
and
exposed-jdbc
as
implementation
. The app project uses this library and generally has little direct knowledge of exposed. It seems that something is going wrong with the transitive dependencies to
sqlite-jdbc
and
exposed-jdbc
. If I explicitly add them to the app project’s jvmMain dependencies, then it works. I don’t see why it should fail, because they’re already provided by the db module.
t

tapac

01/14/2020, 7:48 PM
Could you please file an issue to github with little more details of your configuration and gradle dependency graph?
c

Carter

01/28/2020, 1:51 PM
I think I figured out the root cause, which was accidentally applying the multiplatform plugin to my root build.gradle, in addition to my modules. I think deleting that resolved this issue.
👍 1
View count: 8