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

How do I set the current date in db using Exposed and Kotlin

I want to define a column of type date. This column should hold the current date of the resource created. How do i set this up? I'm new to kotlin. In python, one would impletement it this way: date_created = db.Column(db.DateTime,…
edoc
  • 179
  • 3
  • 9
10
votes
3 answers

Kotlin Exposed does not commit transaction

Following the example provided on Exposed I am not able to read the created tables/data outside the transaction creating it. I am using h2-in-memory database. The exception is: Exception in thread "main" org.h2.jdbc.JdbcSQLException: Table "CITIES"…
rustyfinger
  • 199
  • 2
  • 7
10
votes
5 answers

Is there a way to run raw sql with Kotlin's Exposed library

I'm trying to run some sql specific to postgres and would like to reuse the transaction management within Exposed.
pondermatic
  • 6,453
  • 10
  • 48
  • 63
9
votes
1 answer

Kotlin Exposed - How to insert if not exists, and on conflict?

I've looked around but cannot seem to find how in the world to 'insert if not exists' or 'insert on conflict' using the Exposed SQL framework for Kotlin. I am currently writing raw SQL statements and executing them as is. I don't think I can avoid…
Dev909
  • 115
  • 1
  • 1
  • 5
9
votes
3 answers

Can I mix Ktor with Exposed?

I am writing a service using Ktor and Exposed ORM which apparently isn't async. I am coming from the Python world and back there using a blocking ORM with a async IO library is a sin as it may block all users in thread. Does the same rule apply in…
Kamyar
  • 2,494
  • 2
  • 22
  • 33
9
votes
1 answer

SQL Logging with Exposed in Spring Boot

How do you enable logging of sql queries generated by Exposed in Spring Boot? The following do not work: logging.level.org.jetbrains.exposed.sql: DEBUG logging.level.org.jetbrains.exposed: DEBUG
Josh B
  • 577
  • 5
  • 11
8
votes
2 answers

Kotlin exposed - Entity for table with no identity column

All of the material I can find on Kotlin exposed library assumes that the table has a primary identity column, and so the entities are in most examples shown inherit the IntEntity abstract class. For Example: class UserLocation(id: EntityID) :…
Oxymoron
  • 1,380
  • 2
  • 19
  • 47
8
votes
1 answer

Exposed: How to parse JSON into an Entity class

I have the following user table object & entity class: object UserTable : IntIdTable() { val name = varchar("name", 256) } class User(id: EntityID): IntEntity(id) { companion object : IntEntityClass(UserTable) val name by…
Ilia Choly
  • 18,070
  • 14
  • 92
  • 160
7
votes
1 answer

Kotlin Exposed batch insert not working as documented

I am trying to batch insert records into an SQL table using Kotlin Exposed. I have set up the code as per the Exposed documentation, however, the SQL statements being executed are individual insert statements rather than 1 batch insert statement.…
Owen Kirkeby
  • 115
  • 2
  • 7
7
votes
0 answers

Android application becomes slow when using Android Studio Profiler

What I try to do is get a lot of data about heroes in a game and save it in a DB, I use OkHttp to make request to the server and gson to parse the json and then save the classes I get from gson to the db by using an ORM from Jetbrains called…
Dinu Nicolae
  • 1,019
  • 2
  • 17
  • 42
7
votes
5 answers

How to use Postgresql enum type via Kotlin Exposed ORM?

I have added some Postgresql types to Exposed as extensions. It has two ready types named enumeration and enumerationByName. I tested both of them with no success for mapping a postgre enum type to Kotlin enum class. In both reading and writing it…
Kamyar
  • 2,494
  • 2
  • 22
  • 33
7
votes
1 answer

Maven import dependency Jetbrains Exposed

On the github page of Jetbrains' Exposed,a Kotlin SQL Framework, there is a link to a page where you can get the maven dependency for this library (https://bintray.com/kotlin/exposed/exposed/view#). The same dependecy can also be found on…
OmerSakar
  • 175
  • 2
  • 11
6
votes
1 answer

JetBrains exposed Adding a custom field/column with a value in a slice

I want to add a custom field when doing a complex join with a value Basically something like this: SELECT p.first_name, "Smith" AS "last_name" FROM person p WHERE first_name = "John" In kotlin that would be something like this: PersonTable …
Silvio
  • 151
  • 9
5
votes
1 answer

How to avoid N+1 query problem on kotlin Exposed. (When getting value by DAO's Reference.id.value field)

I use Exposed as O/R Mapper on Kotlin JVM project. (version: 0.17.6) I had trouble with the N+1 query problem when I got a foreign key column's value from DAO API (columns defined by Exposed's reference method). I somehow solve the problem with a…
Koyama Kenta
  • 151
  • 1
  • 5
5
votes
1 answer

How to set cascade type in a One-To-Many relationship in Kotlin Exposed?

I have two entities in a One-To-Many relationship. The "One" entity owns the "Many"'s lifecycle. If the "One" entity is deleted, I want all "Many" entities who belong to the "One" to be deleted automatically. I assume there is a way to set the…
zt1106
  • 53
  • 2
  • 5
1
2 3
16 17