# exposed


08/23/2022, 12:51 PM
Folks, I have a question if you don’t mind - what’s the main reason(s) you’ve chosen Exposed over other solutions?


08/23/2022, 1:07 PM
I like the lightweight API and DSL compared to e.g. SQLDelight. I also did have many runtime performance problems with SQLDelight. In contrast exposed with an H2 database is extremely fast.
🙏 1

Emil Kantis

08/23/2022, 1:43 PM
I'm interested in switching from Exposed to SQLDelight, since I like writing SQL queries and it's hard to unit tests with Exposed entities (although perhaps those entities should only be used for data access and not business logic?)
🙏 1


08/23/2022, 1:52 PM
I choosed Exposed because JPA is too much magic. Exposed is giving me the minimum I need for the persistence layer. To get rid of the manual transactions in my business logic I wrap Exposed in a repository layer.
🙏 2
plus one 2


08/23/2022, 2:07 PM
Mainly due to the implied stability of it being JB backed, and the DSL being lightweight. That said, with the design around global state and a preference to move towards SQL-first we're thinking of switching to SQLDelight once we've validated the PSQL support for our use-cases.
🙏 1


08/23/2022, 2:35 PM
I chose Exposed because it lets me switch between Sqlite for local development and Postgres once my server application is deployed to the cloud without really any code changes. This makes it really easy to check out and build/run a ktor web application on the JVM without lots of local configuration changes.
🙏 1


08/23/2022, 2:39 PM
I was looking for a lightweight and Kotlin native access layer. Since SQLDelight does not support Oracle, this was not an option. I still had Jooq on my list from the past, but since this is fee-based, it didn't make the cut. The fact that Exposed comes from the Jetbrains team was an added bonus.
🙏 1
👍 1

Endre Deak

08/23/2022, 3:33 PM
1. it's lightweight 2. simple 3. type-safe sql statement creation (no raw strings parsed) 4. extensible (easy to add your own functions and use them as they were part of the lib) 5. no magic - I'm using the DSL, not the DAO and even with some boilerplate (which imho is a manageable amount) I have full control over my tables and entities I used it to create new databases but also to connect to existing schemas and in both cases I was amazed how simple and straightforward the work was I even managed to write some simple wrappers around it's
object so I could manage connections across multiple schemas and endpoints
👍 2
🙏 1


08/24/2022, 5:13 AM
JB backed, Kotlin first and no magic. Sometimes I am unsure if stepping away from JPA was the right move. While Exposed removed the magic part, it also introduced a lot of extra code to manage. Especially the repositories with all the hand written queries, and to a lesser extent mapping the domain entities on the tables. While DAO solves some of the query boilerplate, it is yet another class to manage.
🙏 1

Andreas Scheja

08/24/2022, 4:23 PM
In general: type safe sql statements (including nullability), lightweight (we only use the DSL) and no magic 🙂. Sadly we have to work with a rather monolithic database that is shared over multiple applications, so we have one library which defines all the tables and keep the Repositories with the queries in the applications. vs JPA: I like to have as much as possible immutable, which just isn't possible with JPA afaik. Plus, since you have to initialize everything you end up having to initialize everything with null, so you have to work around that framework-forced nullability in your code, which leads to lots of ugly/unnecessary code with `!!
?: error("shouldn't happen")` vs SQLDelight: we have a lot of queries that we assemble during runtime, which doesn't work well with SQLDelight afaik.
❤️ 1
🙏 1


08/25/2022, 9:03 AM
• Kotlin first • Jetbrains backed • Typesafe • Simple API • Can switch b/w different SQL dialects with minimum or no code changes. I use H2 with test data and for other envs use mysql / postgres and can switch b/w based on a conf file loaded. • No annotations or magic I use Ktor as the backend for my projects and I prefer ktor for the same reasons - simple API, no annotations magic.