query.fetchInto(KotlinClass::class)
query.fetchInto(KotlinClass::class.java)
fun <E: Any, R: Record> ResultQuery<R>.fetchInto(klass: KClass<E>): MutableList<E> {return this.into(klass.java)}
- It’d be neat if the generated record types could have their various members explicitly marked as nullable so that they’re `?` types rather than `!` types. However, maybe that can be done by annotating them `@Nullable` — I forget if kotlin’s platform type integration takes that into account.
- fetchOne() (or its equivalent extension function) could return `R?` instead of `R!`
--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/968881B1-F851-4AD6-AF4D-E03F141EEEBB%40mpierce.org.
--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/0a5a7ec5-3a9a-49cc-8da9-36cd7246849b%40googlegroups.com.
Hi Marshall,Thank you very much for your suggestion. Is that something you think would be easy to integrate in jOOQ without adding a dependency on Kotlin libraries? How does supporting that out of the box compare to an extension method (at least for now)? I would imagine that this could be implemented entirely outside of jOOQ, too...Thanks,Lukas
On Mon, Sep 30, 2019 at 4:39 PM Marshall Pierce <mars...@mpierce.org> wrote:
--One more...It'd make integration with Kotlin coroutines (OK, that's not just Kotlin the language...) easier/possible to have something like `transactionResult` that instead of taking a `TransactionCallable` and doing all the ManagedBlocker bits, took something whose `run()` (or equivalent) was a `suspend` function. In Kotlinese, that could be simply a function type: `suspend (Configuration) -> T`.My current use case is that I'd like to be able to kick off some fire-and-forget async work inside a transaction, and for various reasons I'd prefer to have that be done via coroutines rather than `CompletableFuture` and friends (e.g. coroutine context carries over to child coroutines, unlike threadlocals, and other such things).
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq...@googlegroups.com.
There's little downside to having this exposed as an extension method (extension methods can only access public members but not an issue here), and I think that's really the only reasonable way to do it. Technically I could provide a TransactionalCallable with a runBlocking{} inside it, and that would compile, but also lose much of the benefits of using coroutines (won't carry over coroutine context, ties up a thread). Instead, I threw together a quick proof of concept of one way it could work: https://github.com/jOOQ/jOOQ/compare/master...marshallpierce:kotlin-suspend-txn-result?expand=1This way does work and was "easy", but now there's essentially a duplicated copy of `transactionResult0`, which is pretty sad, and it's in `org.jooq.impl` to get access to DefaultTransactionContext and friends, creating a split package which will make JPMS upset.If there was another way to implement the listener stuff before and exception stuff after that didn't involve package-private classes (and hopefully also avoiding copy-and-paste code...), then the extension function could be in a separate package, and indeed a separate project entirely.
Or, if there isn't an option to use public types, could *gasp* actually use JPMS to expose the org.jooq.impl package to org.jooq.kotlin_stuff_goes_here. Mark Reinhold would be so happy.