Skip to content

Commit

Permalink
Merge pull request #45609 from LarsSven/ls/kotlin-panache-nullable
Browse files Browse the repository at this point in the history
Allow null for query parameters in Kotlin panache
  • Loading branch information
geoand authored Jan 15, 2025
2 parents 552d558 + dbdc588 commit 3f0743c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
* @see [PanacheRepositoryBase.stream]
*/
@GenerateBridge
fun find(query: String, vararg params: Any): PanacheQuery<Entity> =
fun find(query: String, vararg params: Any?): PanacheQuery<Entity> =
throw implementationInjectionMissing()

/**
Expand All @@ -129,7 +129,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
* @see [PanacheRepositoryBase.stream]
*/
@GenerateBridge
fun find(query: String, sort: Sort, vararg params: Any): PanacheQuery<Entity> =
fun find(query: String, sort: Sort, vararg params: Any?): PanacheQuery<Entity> =
throw implementationInjectionMissing()

/**
Expand All @@ -142,7 +142,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
* @see [PanacheRepositoryBase.stream]
*/
@GenerateBridge
fun find(query: String, params: Map<String, Any>): PanacheQuery<Entity> =
fun find(query: String, params: Map<String, Any?>): PanacheQuery<Entity> =
throw implementationInjectionMissing()

/**
Expand All @@ -156,7 +156,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
* @see [PanacheRepositoryBase.stream]
*/
@GenerateBridge
fun find(query: String, sort: Sort, params: Map<String, Any>): PanacheQuery<Entity> =
fun find(query: String, sort: Sort, params: Map<String, Any?>): PanacheQuery<Entity> =
throw implementationInjectionMissing()

/**
Expand Down Expand Up @@ -217,7 +217,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
* @see [PanacheRepositoryBase.stream]
*/
@GenerateBridge
fun list(query: String, vararg params: Any): List<Entity> =
fun list(query: String, vararg params: Any?): List<Entity> =
throw implementationInjectionMissing()

/**
Expand All @@ -232,7 +232,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
* @see [PanacheRepositoryBase.stream]
*/
@GenerateBridge
fun list(query: String, sort: Sort, vararg params: Any): List<Entity> =
fun list(query: String, sort: Sort, vararg params: Any?): List<Entity> =
throw implementationInjectionMissing()

/**
Expand All @@ -246,7 +246,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
* @see [PanacheRepositoryBase.stream]
*/
@GenerateBridge
fun list(query: String, params: Map<String, Any>): List<Entity> =
fun list(query: String, params: Map<String, Any?>): List<Entity> =
throw implementationInjectionMissing()

/**
Expand All @@ -261,7 +261,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
* @see [PanacheRepositoryBase.stream]
*/
@GenerateBridge
fun list(query: String, sort: Sort, params: Map<String, Any>): List<Entity> =
fun list(query: String, sort: Sort, params: Map<String, Any?>): List<Entity> =
throw implementationInjectionMissing()

/**
Expand Down Expand Up @@ -325,7 +325,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
* @see [PanacheRepositoryBase.list]
*/
@GenerateBridge
fun stream(query: String, vararg params: Any): Stream<Entity> =
fun stream(query: String, vararg params: Any?): Stream<Entity> =
throw implementationInjectionMissing()

/**
Expand All @@ -342,7 +342,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
* @see [PanacheRepositoryBase.list]
*/
@GenerateBridge
fun stream(query: String, sort: Sort, vararg params: Any): Stream<Entity> =
fun stream(query: String, sort: Sort, vararg params: Any?): Stream<Entity> =
throw implementationInjectionMissing()

/**
Expand All @@ -357,7 +357,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
* @see [PanacheRepositoryBase.list]
*/
@GenerateBridge
fun stream(query: String, params: Map<String, Any>): Stream<Entity> =
fun stream(query: String, params: Map<String, Any?>): Stream<Entity> =
throw implementationInjectionMissing()

/**
Expand All @@ -373,7 +373,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
* @see [PanacheRepositoryBase.list]
*/
@GenerateBridge
fun stream(query: String, sort: Sort, params: Map<String, Any>): Stream<Entity> =
fun stream(query: String, sort: Sort, params: Map<String, Any?>): Stream<Entity> =
throw implementationInjectionMissing()

/**
Expand Down Expand Up @@ -447,7 +447,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
* @return the number of entities counted.
*/
@GenerateBridge
fun count(query: String, vararg params: Any): Long = throw implementationInjectionMissing()
fun count(query: String, vararg params: Any?): Long = throw implementationInjectionMissing()

/**
* Counts the number of this type of entity matching the given query, with named parameters.
Expand All @@ -457,7 +457,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
* @return the number of entities counted.
*/
@GenerateBridge
fun count(query: String, params: Map<String, Any>): Long =
fun count(query: String, params: Map<String, Any?>): Long =
throw implementationInjectionMissing()

/**
Expand Down Expand Up @@ -493,7 +493,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
* @see [PanacheRepositoryBase.deleteAll]
*/
@GenerateBridge
fun delete(query: String, vararg params: Any): Long = throw implementationInjectionMissing()
fun delete(query: String, vararg params: Any?): Long = throw implementationInjectionMissing()

/**
* Delete all entities of this type matching the given query, with named parameters.
Expand All @@ -507,7 +507,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
* @see [PanacheRepositoryBase.deleteAll]
*/
@GenerateBridge
fun delete(query: String, params: Map<String, Any>): Long =
fun delete(query: String, params: Map<String, Any?>): Long =
throw implementationInjectionMissing()

/**
Expand Down Expand Up @@ -567,7 +567,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
* @return the number of entities updated.
*/
@GenerateBridge
fun update(query: String, vararg params: Any): Int = throw implementationInjectionMissing()
fun update(query: String, vararg params: Any?): Int = throw implementationInjectionMissing()

/**
* Update all entities of this type matching the given query, with named parameters.
Expand All @@ -577,7 +577,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
* @return the number of entities updated.
*/
@GenerateBridge
fun update(query: String, params: Map<String, Any>): Int =
fun update(query: String, params: Map<String, Any?>): Int =
throw implementationInjectionMissing()

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
* @see [list] list
*/
@GenerateBridge
fun find(query: String, vararg params: Any): PanacheQuery<Entity> =
fun find(query: String, vararg params: Any?): PanacheQuery<Entity> =
throw INSTANCE.implementationInjectionMissing()

/**
Expand All @@ -117,7 +117,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
* @see [list] list
*/
@GenerateBridge
fun find(query: String, sort: Sort, vararg params: Any): PanacheQuery<Entity> =
fun find(query: String, sort: Sort, vararg params: Any?): PanacheQuery<Entity> =
throw INSTANCE.implementationInjectionMissing()

/**
Expand All @@ -129,7 +129,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
* @see [list] list
*/
@GenerateBridge
fun find(query: String, params: Map<String, Any>): PanacheQuery<Entity> =
fun find(query: String, params: Map<String, Any?>): PanacheQuery<Entity> =
throw INSTANCE.implementationInjectionMissing()

/**
Expand All @@ -142,7 +142,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
* @see [list] list
*/
@GenerateBridge
fun find(query: String, sort: Sort, params: Map<String, Any>): PanacheQuery<Entity> =
fun find(query: String, sort: Sort, params: Map<String, Any?>): PanacheQuery<Entity> =
throw INSTANCE.implementationInjectionMissing()

/**
Expand Down Expand Up @@ -200,7 +200,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
*/
@CheckReturnValue
@GenerateBridge
fun list(query: String, vararg params: Any): Uni<List<Entity>> =
fun list(query: String, vararg params: Any?): Uni<List<Entity>> =
throw INSTANCE.implementationInjectionMissing()

/**
Expand All @@ -215,7 +215,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
*/
@CheckReturnValue
@GenerateBridge
fun list(query: String, sort: Sort, vararg params: Any): Uni<List<Entity>> =
fun list(query: String, sort: Sort, vararg params: Any?): Uni<List<Entity>> =
throw INSTANCE.implementationInjectionMissing()

/**
Expand All @@ -229,7 +229,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
*/
@CheckReturnValue
@GenerateBridge
fun list(query: String, params: Map<String, Any>): Uni<List<Entity>> =
fun list(query: String, params: Map<String, Any?>): Uni<List<Entity>> =
throw INSTANCE.implementationInjectionMissing()

/**
Expand All @@ -244,7 +244,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
*/
@CheckReturnValue
@GenerateBridge
fun list(query: String, sort: Sort, params: Map<String, Any>): Uni<List<Entity>> =
fun list(query: String, sort: Sort, params: Map<String, Any?>): Uni<List<Entity>> =
throw INSTANCE.implementationInjectionMissing()

/**
Expand Down Expand Up @@ -319,7 +319,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
*/
@CheckReturnValue
@GenerateBridge
fun count(query: String, vararg params: Any): Uni<Long> =
fun count(query: String, vararg params: Any?): Uni<Long> =
throw INSTANCE.implementationInjectionMissing()

/**
Expand All @@ -331,7 +331,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
*/
@CheckReturnValue
@GenerateBridge
fun count(query: String, params: Map<String, Any>): Uni<Long> =
fun count(query: String, params: Map<String, Any?>): Uni<Long> =
throw INSTANCE.implementationInjectionMissing()

/**
Expand Down Expand Up @@ -382,7 +382,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
*/
@CheckReturnValue
@GenerateBridge
fun delete(query: String, vararg params: Any): Uni<Long> =
fun delete(query: String, vararg params: Any?): Uni<Long> =
throw INSTANCE.implementationInjectionMissing()

/**
Expand All @@ -398,7 +398,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
*/
@CheckReturnValue
@GenerateBridge
fun delete(query: String, params: Map<String, Any>): Uni<Long> =
fun delete(query: String, params: Map<String, Any?>): Uni<Long> =
throw INSTANCE.implementationInjectionMissing()

/**
Expand Down Expand Up @@ -453,7 +453,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
*/
@CheckReturnValue
@GenerateBridge
fun update(query: String, vararg params: Any): Uni<Int> =
fun update(query: String, vararg params: Any?): Uni<Int> =
throw INSTANCE.implementationInjectionMissing()

/**
Expand All @@ -465,7 +465,7 @@ interface PanacheRepositoryBase<Entity : Any, Id : Any> {
*/
@CheckReturnValue
@GenerateBridge
fun update(query: String, params: Map<String, Any>): Uni<Int> =
fun update(query: String, params: Map<String, Any?>): Uni<Int> =
throw INSTANCE.implementationInjectionMissing()

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ open class AddressDao(private val dummyService: DummyService) :
}
}

override fun count(query: String, params: Map<String, Any>): Long = shouldBeOverridden()
override fun count(query: String, params: Map<String, Any?>): Long = shouldBeOverridden()
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import jakarta.enterprise.context.ApplicationScoped

@ApplicationScoped
open class PersonRepository : PanacheRepository<Person> {
override fun count(query: String, params: Map<String, Any>): Long {
override fun count(query: String, params: Map<String, Any?>): Long {
return INSTANCE.count(Person::class.java, query, params)
}
}

0 comments on commit 3f0743c

Please sign in to comment.