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
0
votes
0 answers

When using Exposed's method "createMissingTablesAndColumns", I get a NoSuchElementException

I'm using 0.22.1 Exposed libs (core/dao/jdbc) and when I use "SchemaUtils.createMissingTablesAndColumns", my tables are created but I get an Exception. If I relaunch the server with a new column, I get the same Exception and the update isn't…
0
votes
1 answer

DATE_ADD(start_date, INTERVAL 1 DAY) with Kotlin Exposed;

How to use date functions in kotlin-exposed? I have to add x days to Column and compare with date. open class DBTable(tableName: String) : Table(tableName) { val id = integer("id").autoIncrement().primaryKey() } object UserAuthorizationDataTable…
Tech Drago
  • 27
  • 2
  • 8
0
votes
1 answer

can you join two tables and result with an obj (from first table) containing a list of obj(from the second table)

First of all my code: Table 1: object Company : Table() { val name = varchar("pk_name", 250) override val primaryKey = PrimaryKey(name, name = "pk_company_constraint") } Table 2&3: object Sector : IntIdTable() { val name =…
Felix
  • 1
0
votes
1 answer

Exposed SQLite connection fails with SQLITE_BUSY

I'm trying to build an application using Ktor and Exposed with SQLite. Unfortunately my application keeps crashing. This is my database connection: class DatabaseFactory(connection: DatabaseConnection) { init { connect() …
multiholle
  • 3,050
  • 8
  • 41
  • 60
0
votes
1 answer

How can I select aliased column in kotlin exposed

How can I select group by aliased column? I am using kotlin-exposed. fun getSubscribeInfoByRoleName(roleName: String): List { return SchemaSubscribersTable.join(SchemaVersionScheduleTable, JoinType.INNER, null, null) { …
0
votes
1 answer

Kotlin Exposed Sum on condition (CaseWhenElse)

I have a table with data structure like : id type cityName regDate 1249 0 City1 2019-10-01 I want to get result output of unique cities and the number of registrations in it per month as a list of data class objects of data class…
gencomrrr
  • 3
  • 3
0
votes
1 answer

Is it still possible to get 'NullPointerException' on property 'x' when building an Object from a result of a query with 'Where x is not null'

I am using exposed in one project, and I have a table lets call it TableX with two properties property1 and x knowing that x is nullable I added TableX.x.isNotNull() to my query so I can ignore null rows!. And I have Object1 with also two properties…
HSLM
  • 1,692
  • 10
  • 25
0
votes
2 answers

How can we determine, that we are already in transaction block?

I use exposed without DAO with caffeine cache. The common usage is transaction { val row = rowService.getById(1)!! } RowService tries to find row in cache first, if negative, runs query againt database. I suspect that transaction block even…
abi
  • 99
  • 8
0
votes
0 answers

Is It Possible To Handle Invalid References (SQL Server)?

I've very much enjoyed being able to shorten my code by using reference in my Table objects as well as referencedOn and referrersOn in my Entities. But as I've gotten further with my project, I've realized that I might have to undo all that work and…
Steph
  • 831
  • 6
  • 19
0
votes
1 answer

Kotlin Nullable Any

I am new to Kotlin. I am facing the following problem. I have a function like this, fun updateAfterFind(updateColumn:Map, Any?>): Boolean{ ExposedUser.update( {ExposedUser.id eq 123} ){ for (column in updateColumn){ …
BhaskerYadav
  • 569
  • 3
  • 24
0
votes
1 answer

Query with casting in WHERE

I'm learning this wonderful library, however while simple queries work, I'm confused how to write something that not in library FAQ. For example, create table if not exists ticks (id bigserial not null constraint ticks_pkey primary key, …
abi
  • 99
  • 8
0
votes
1 answer

How To Compare Months/Days in Kotlin Exposed?

I am trying to query for events in SQL Server that are within a time frame but discarding the year because I am looking for yearly events. I'm trying to build a query by comparing months and month days to a their integer equivalents, but there…
Steph
  • 831
  • 6
  • 19
0
votes
1 answer

Can I get a TableView column to use a Kotlin Exposed transaction when referencing a property?

When using TornadoFX, TableView columns are established like this: tableview(list) { column("ColumnName", ObjectType::property) ... } This is normally fine, but in my case I'm using a Kotlin Exposed entity that's using a reference…
Steph
  • 831
  • 6
  • 19
0
votes
2 answers

SELECT EXISTS(SELECT 1 FROM table WHERE...) in Exposed

Is it possible to do something like this in Exposed to check the existence of a row? SELECT EXISTS(SELECT 1 FROM table WHERE...)
F. Caron
  • 638
  • 7
  • 19
0
votes
1 answer

Inserting data into database returns MismatchedInputException error

I am trying to insert some data into the database, and am getting the following error: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `org.joda.time.DateTime` (although at least one Creator exists): no…
Rodrigo Batista
  • 383
  • 1
  • 6
  • 16