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
5
votes
1 answer

JetBrains Exposed throwing an error when trying to access first row of select query

When trying to fetch the first row from my transaction, I receive an error: java.lang.IllegalStateException: No transaction in context. My code looks like this: fun loadPlayer(client: Client): PlayerLoadResult { var player = transaction { …
Jaquarh
  • 6,493
  • 7
  • 34
  • 86
5
votes
1 answer

NoClassDefFoundError when using Exposed

I'm using Exposed as my database library and I'm getting these errors when I try to run my code: Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/reflect/full/KClasses at org.jetbrains.exposed.sql.Table.clone(Table.kt:196) …
shiftpsh
  • 1,926
  • 17
  • 24
4
votes
1 answer

String primary key with Jetbrains' Exposed library - Kotlin

I'm having problems figuring out how to write a table with a string primary key and have an Entity of the table too. Whether I put IdTable as the Table type or try to use it with a plain Table nothing works.
Michael Scofield
  • 128
  • 2
  • 11
4
votes
2 answers

Index is not used when using Exposed with DataSource with Postgres

I'm facing an unexpected behavior when using Exposed with a DataSource (I tried apache DBCP and HikariCP). Setup: single table (test) with id and flag fields with an index on flag. Query: SELECT * from test where flag=1 limit 1; When run manually,…
roman-roman
  • 2,746
  • 19
  • 27
4
votes
1 answer

How to insert in Kotlin Exposed a record with the foreign key?

I cannot find in Kotlin Exposed documentation the way how to insert a record with the foreign key: object DocumentTable : IntIdTable() { val description = varchar("desc", 200) } object TransactionTable : IntIdTable() { val amount =…
user3514920
  • 141
  • 1
  • 3
4
votes
1 answer

How does sorting work with limit in kotlin exposed model?

I have following snippet of code: UserDataModel .find { UserDataTable.type eq type and ( UserDataTable.userId eq userId ) } …
4
votes
1 answer

How can I serialize kotlin exposed sql dao

I use kotlin exposed sql in my project I created kotlin object for my table also I created DAO as is in example all working as should, but when I want return List of my DAO objects I get: com.fasterxml.jackson.databind.JsonMappingException: Infinite…
Sebastian
  • 166
  • 2
  • 16
4
votes
1 answer

Exposed Kotlin. Problem with cyrillic encoding

I tryed to fix a problem with encodings. So, I sent from 'Postman', from web browser request to server, where I search data in database by keys in request. Request can be like…
Sergey Grishin
  • 392
  • 2
  • 16
3
votes
0 answers

Query with 2 joins and subquery using kotlin-exposed

I have such SQL query: SELECT parent_id, e.season_number, max_seasons.max_episode_number, b.start_year FROM episodes e JOIN basics b USING(title_id) JOIN ( SELECT e.season_number, max(episode_number) AS max_episode_number FROM episodes e …
Andrey
  • 433
  • 1
  • 5
  • 19
3
votes
1 answer

Exposed ORM: DSL vs DAO in Many-to many relationships best practices

I am setting up some many-to-many relationships and have so far been using the Exposed DSL pattern (as opposed to DAO). However, creating many-to-many relationships seem to only be possible using the DAO approach. I know it is probably fine to use…
Stuart
  • 151
  • 7
3
votes
1 answer

Can not start new kotlin multiplatform library with dependency on exposed library

I want to use jetbrains exposed library in a kotlin multiplatform library I am writing. How do I do this? I am getting a gradle build error that it can not find everything it needs for exposed. Here is my gradle build sourceSets { val commonMain…
Kyle M
  • 119
  • 7
3
votes
1 answer

Update table column with another column value [Exposed Kotlin]

Exposed version: 0.28.1 Kotlin version: 1.5.0 Database: PostgreSQL 9.4 Hi, I´m newbie with Exposed ORM Framework. I need to update a table column value with another column value in the same table, the two column types are datetime. On PostgreSQL…
leoLR
  • 462
  • 2
  • 6
  • 21
3
votes
2 answers

How to disable SQL parameters logging in Exposed?

I use the default Exposed framework configuration, which has the built-in logging of SQL statements that the framework creates for the database calls. As a result, I see SQL statements in the logs in the following format: [...] DEBUG Exposed -…
Ilya Zinkovich
  • 4,082
  • 4
  • 25
  • 43
3
votes
1 answer

How do you implement Table Inheritance in Kotlin Exposed?

Example: I have a base table called Pet with a BirthDate and Name columns. I have a two more tables that derive from that table, one called PetDog table with column NumberOfTeeth and another called PetBird table with column BeakColor. How to…
oznecro
  • 457
  • 5
  • 16
3
votes
3 answers

Handling subquery in a Kotlin Exposed framework

Is Exposed 0.27.1 capable to translate the following SQL statement? SELECT FirstName, LastName, (SELECT COUNT(O.Id) FROM "Order" O WHERE O.CustomerId = C.Id) AS OrderCount FROM Customer C; Here is what I tried but unfortunately the…
trimtosize
  • 213
  • 2
  • 10
1
2
3
16 17