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

How to get the inserted row in Kotlin Exposed?

Here is how we get the id of the added row (source): val munichId = Cities.insert { it[name] = "Munich" } get Cities.id What about getting the whole row? I use map for select operations but it does not work for insert.
Alperen
  • 3,772
  • 3
  • 27
  • 49
2
votes
0 answers

Should I define constraints on Jetbrain's Exposed, even though I don't use schema generation?

I am developing with Jetbrains Exposed SQL framework Considering I never use it's schema creation facilities and I use handmade sql scripts to generate/migrate database schema, is there any point on defining foreign key cascade behaviour, uniques…
magnomp
  • 353
  • 2
  • 8
2
votes
0 answers

Make many to many relation in Jetbrains exposed (Kotlin exposed)

Just wondering if anyone has any examples or has ever done something similar, and could help me with this. My structure is as follows. User has multiple roles Roles have multiple Permissions, and the relevant users that match Permissions have…
John Smith
  • 49
  • 3
2
votes
1 answer

Kotlin Exposed create entity with reference

I am trying to write a CRUD service using Exposed on Kotlin. I have a table with many-to-one reference. When I am trying to do an insert I am getting java.lang.IllegalStateException: No transaction in context. Here is table and entity object…
Alex Bondar
  • 1,167
  • 4
  • 18
  • 35
2
votes
1 answer

How can I call a sequence.nextVal using kotlin exposed

We have a project where we use a Postgres sequence for generating an increasing number, but I cannot figure out how to actually use the sequence in kotlin exposed. I see there is a Sequence class and a NextVal class encapsulating a sequence but…
2
votes
0 answers

postgres update failed, when comparing a string whose length is greater than 255+ with a column value

The issue is basically happening, when i am comparing a string whose length is greater than 255+ with a column value, whose code is as follows, transaction { TableUserAccessToken.update({ (TableUserAccessToken.accessToken…
Reprator
  • 2,859
  • 2
  • 32
  • 55
2
votes
1 answer

TestContainers and Mysql : Access denied for user ''@'172.17.0.1' (using password: NO)

I wrote a simple repository to test Kotlin Exposed with TestContainers. The database that I use is mysql. Here is my code : class StudentsRepositoryTest: ShouldSpec({ val container = getMysqlContainer() val mysqlJdbcUrl =…
Dimitri
  • 8,122
  • 19
  • 71
  • 128
2
votes
1 answer

NoSuchMethod Error while using Exposed with H2

I'm trying to used exposed and h2 for storage inside a ktor server. After setting up an in memory connection with Database.connect("jdbc:h2:mem:test", driver = "org.h2.Driver") Whenever I try to read/write to the database I get the following…
Morgan
  • 303
  • 2
  • 15
2
votes
1 answer

How to map a count() value from a QueryAlias in Exposed

How do I map a count() value from ResultRow using QueryAlias in Exposed Or am I doing something completely wrong? val countAlias = EventTable.join(AttendeeEventTable, JoinType.INNER) .slice(EventTable.id, EventTable.id.count()) .selectAll() …
oletjens
  • 31
  • 4
2
votes
1 answer

Connecting to a database after creating it with Kotlin Exposed

I'm using jetbrains' exposed library to create and populate a database. The database does not exist, and I am creating it. However I could not find a simple way to connect to the SQL engine, create a database and connect to that database without…
jlengrand
  • 12,152
  • 14
  • 57
  • 87
2
votes
0 answers

How to correctly use shadowJar while deploying a Ktor + Exposed backend?

Here's my shadowJar task shadowJar { archiveName "server.jar" mainClassName = "myapp.ApplicationKt" manifest { attributes( 'Class-Path': project.configurations.compile.collect { it.getName() }.join(' ') ) …
Aditya Anand
  • 776
  • 2
  • 9
  • 29
2
votes
1 answer

How set id via Exposed

I create object and dao class for work with sql object UserTable : IdTable("User") { val parameters = reference("search_parameters_id", SearchParametersTable) override val id = integer("id").entityId() override val primaryKey =…
2
votes
1 answer

How connect tot Google Cloud SQL via Exposed

I develop app on GAE using Kotlin, Ktor. Database is CloudSQL. For connect to it use Exposed library Database.connect( "jdbc:postgresql://cloudsql/::", driver="org.postgresql.Driver", …
2
votes
2 answers

How to get createdAt and lastModified fields with proper behavior using Kotlin's Exposed ORM?

data class User( var name: String? = null, val mobile: String, var email: String? = null ) : Principal, BaseTable() Ideally, what I would want is to have the common logic for the generation of the lastModified, createdAt fields to…
Aditya Anand
  • 776
  • 2
  • 9
  • 29
2
votes
0 answers

Exception occurs when trying to connect to MS SQLSERVER from android with Exposed

import android.os.AsyncTask import org.jetbrains.exposed.sql.Database import org.jetbrains.exposed.sql.Table import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction class DatabaseConnect :…
LenardNagy
  • 21
  • 2