A dynamic, type-safe way to write your queries
TODO
Gradle Kotlin DSL
Add the KSP Gradle plugin to your build file
plugins {
id("com.google.devtools.ksp") version "2.3.0"
}Add this library to your build file and register it with KSP
dependencies {
implementation("ch.icken:panache-kotlin-dsl:0.1.1")
ksp("ch.icken:panache-kotlin-dsl:0.1.1")
}Optionally configure the behavior
ksp {
arg("addGeneratedAnnotation", "true")
}Gradle Groovy DSL
TODO
Apache Maven
TODO
- Quarkus version
3.24.0or newer- Dependency
io.quarkus:quarkus-hibernate-orm-panache-kotlinis required
- Dependency
- Kotlin version
2.1.21or newer - KSP version
2.1.21-2.0.1or newer- Note: Only KSP2 is supported. KSP1 is not supported!
- When using any KSP version before
2.3.0, your KSP version needs to match your Kotlin version. This is a strict requirement!
For example, when your Kotlin version is2.1.21, your KSP version needs to be built for and start with the same version, such as2.1.21-2.0.1
- Supports the following expressions in a type-safe and null-safe way for all columns
eq,neq,lt,gt,lte,gte,in,notIn,between, andnotBetween
- Supports
likeandnotLikeexpressions in a null-safe way for String columns - Supports
andandorexpressions for building up a query - Adds the
PanacheSingleResultsealed class andsingleResultSafe()extension function to return a single result without throwing exceptions.- Allows you to handle no/multiple results with a
when (result) { ... }block instead of try-catching
- Allows you to handle no/multiple results with a
- Generate
Columns for non-transient and non-mapped fields in Panache entities - Generate query entry point extension functions for entities with Panache companion objects
whereto start building a SELECT/DELETE queries, which may be chained to other Panache functionsupdatewith setters to bulk-update multiple rows at once- Single expression
updateAllto update all rows without requiring a WHERE clause - Single expression
count,delete,find,stream,single,singleSafe, andmultiple
- Allows for overriding the generated
Column's type parameter using@ColumnType- Especially useful when using a JPA
@Converterwhen the field's type is different to the column's type
- Especially useful when using a JPA
- Optionally annotate generated code with
@Generatedso it can be excluded from test coverage reporting
- Code generation does not handle fields of generic types (e.g.
List<E>,Set<E>, etc.), but as far as I'm aware this is difficult to get working with Hibernate anyway. Consider using@ColumnTypefrom this library in combination with a JPA@Converteron such a field.
These features will be added some time in the future. Please do submit an issue if you'd like these sooner rather than later :)
- DSL for sorting expressions