Questions tagged [kotlin-exposed]

Exposed is Kotlin's SQL library. Use with the [kotlin] tag

Exposed is a SQL library made by Jetbrains (the creators of Kotlin)

Exposed is a prototype for a lightweight SQL library written over JDBC driver for Kotlin language. It does have two layers of database access: typesafe SQL wrapping DSL and lightweight data access objects

245 questions
3
votes
1 answer

Multiple DAO update in single query through Exposed?

normally I can create a SQL query like this to update two separate tables: UPDATE Books, Orders SET Orders.Quantity = Orders.Quantity + 2, Books.InStock = Books.InStock - 2 WHERE Books.id = Orders.BookID AND Orders.id = 1002; DAO would…
Last61474
  • 43
  • 3
3
votes
1 answer

how to convert kotlin Exposed ResultSet to Entity?

I use kotlin Exposed with DAO style, and have a code like below. here, Nodes is Table of Exposed and Node is Entity which is created from Nodes table, and has Long Id. transaction { TransactionManager.current().exec( "select…
takehiro iyatomi
  • 753
  • 1
  • 7
  • 20
3
votes
1 answer

Avoid code duplication in insert and update statements using JetBrains Exposed

I'm using Exposed in a new project and I'm noticing that for insert and update statements I have to duplicate all the assignments for record values. An example: val orderId = Orders.insert { it[orderType] = orderDTO.orderType …
davioooh
  • 23,742
  • 39
  • 159
  • 250
3
votes
1 answer

How to disable logs of Exposed Framework?

I have a kotlin desktop application with gradle builder. I added Exposed ORM framework for my sqlite DB. Then I noticed this framework generates a lot of logs that I don't want to see in console (I want to see only my logs generated…
kerosinkin
  • 45
  • 5
3
votes
1 answer

Is it safe to use Jetbrains exposed library with Ktor and perform the database transaction inside a coroutine?

I am new to Kotlin and recently started working on Ktor server. To perform database operations server needs to communicate with MySql server. I started using JetBrains Exposed library to write database operations. I wrote a suspended function to…
3
votes
2 answers

How to add multiple or filter conditions based on incoming parameters using exposed?

I have to add or conditions using the parameter values to the query. Example: select * from users where email = "abc@xyz.com" or phone="1234123412"; The user might send both fields or only one. I want to do this in a loop for each field and add each…
Jebin
  • 702
  • 13
  • 33
3
votes
1 answer

How to do batch updates?

I am trying to update a specific column on a list of rows in MySql using Exposed. Actually Exposed supports a batchInsert, but there is nothing similar to a batchUpdate, is there any workaround for this? NOTE: the table is not an IdTable.
3
votes
1 answer

Kotlin Exposed: How to create prepared statement or avoid SQL Injection?

I use Kotlin Exposed to create queries. But I faced a problem when I have to use a parameter recieved from a client: private fun accountInfo(msg: AccountInfoMsg) { transaction { val accountInfo =…
nllsdfx
  • 900
  • 14
  • 30
3
votes
1 answer

Is there any way to declare a scope extension to third party library kotlin class?

I'm trying a program build with Jetbrain/Exposed as ORM library and TornadoFX which is a kotlin version wrapper of JavaFX as UI Framework. There is a problem that an entity's class property is delegated by Exposed. object Paintings: UUIDTable() { …
LaysDragon
  • 83
  • 1
  • 6
3
votes
0 answers

Can Kotlin Exposed be used from Java code

I know that you in general can call Kotlin code from Java, but is this something worth doing when doing Exposed? Or is it's API too tied to the idomatic way of coding Kotlin. Has any one experience with using Kotlin Exposed from Java code? And does…
2
votes
1 answer

Kotlin Exposed: Proper way to create a One To Many Relationship?

I want to create an One-To-Many Relationship from the Order Entity to the OrderProductAmount Entity. I need this, because for each Order I need to know which Product's it contains and what the amount of each Product in the Order is, as one order can…
tonik
  • 465
  • 1
  • 4
  • 15
2
votes
1 answer

Additional fields in many-to-many references

I need to create many-to-many reference that will contain additional fields. Eg I have object Servers : UUIDTable("servers") { val name = text("name") val description = text("description").nullable() val link = text("link").nullable() …
zxcqirara
  • 21
  • 3
2
votes
1 answer

Get the max value using kotlin-exposed

I want to simulate this query using kotlin exposed framework: SELECT max(episodes.season_number) FROM episodes WHERE episodes.parent_id = 944947 I tried the next one query: fun countSeasonsForParentId(id: Int) = transaction { …
Andrey
  • 433
  • 1
  • 5
  • 19
2
votes
1 answer

How to get the inserted row id in Kotlin Exposed inserting with raw sql?

i am inserting a row in a table with kotlin exposed using a raw sql. Is it possible to return the row id? val sql: String = """ INSERT INTO customer (name, city) VALUES ('Tom',…
nusmanov
  • 451
  • 4
  • 15
2
votes
0 answers

Generate SQLs and prepared SQLs from DSL and DAO without `Database.connect` or having a `Transaction` with Kotlin Exposed

I am trying to take advantage of Exposed's type-safe DSL on top of Vert.x SQL Client to have both type-safety and throughput. I know currently Exposed doesn't support any reactive/async/non-blocking database clients yet (see #456, #732, etc.), but a…
Shreck Ye
  • 1,591
  • 2
  • 16
  • 32
1 2
3
16 17