Mapping library compatible with java 16

77 views
Skip to first unread message

David Karlsen

unread,
May 4, 2021, 5:16:57 AM5/4/21
to jooq...@googlegroups.com
Hi folks.

I've been a happy user of https://github.com/arnaudroger/SimpleFlatMapper which fits well with jooq, but it might seem that development of this has stalled (last commit and release in May last year), and I am experiencing problems with it on java 16.

Are there any good alternatives - that run well on java 16?

--

Lukas Eder

unread,
May 4, 2021, 5:29:18 AM5/4/21
to jOOQ User Group
Hi David,

What are you using it for?

Cheers,
Lukas

--
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/CAGO7Ob3gADNRA7ow8PEuiZPs8B77S9H4szXF%3DSJYUxO%2BOgJhAQ%40mail.gmail.com.

David Karlsen

unread,
May 4, 2021, 7:12:15 AM5/4/21
to jooq...@googlegroups.com
I use fetchInfo to map from jooq results to my domain objects.

Lukas Eder

unread,
May 4, 2021, 7:32:30 AM5/4/21
to jOOQ User Group
Yes, I figured that's what you're using it for on a very high level, but what are you doing *specifically*? (E.g. some example mappings) :) 

Because jOOQ 3.15 will ship with quite a few new features, which you may like. Maybe, you won't need a third party library anymore.

Lukas Eder

unread,
May 6, 2021, 3:12:28 AM5/6/21
to jOOQ User Group
For context, here are some examples of what I'm currently working on:

So far, the example at the bottom (using nested row() and array() expressions) works on PostgreSQL with native support. I'm hoping to get this to work also on other dialects via SQL/JSON or SQL/XML emulations.

David Karlsen

unread,
May 21, 2021, 7:00:01 PM5/21/21
to jooq...@googlegroups.com
Example:

override fun listAccounts(customerKey: CustomerKey, pageable: Pageable): Set<Account> {
return dslContext
.select()
.from(T_ACCOUNT.join(T_CUSTOMER_ACCOUNT).onKey().join(T_CUSTOMER).onKey())
.where(
T_CUSTOMER
.ORGID
.eq(customerKey.orgId)
.and(T_CUSTOMER.CUSTOMERID.eq(customerKey.customerId)))
.limit(pageable.pageSize)
.offset(pageable.offset.toInt())
.fetchGroups(T_ACCOUNT, T_CUSTOMER)
.entries
.map { map(it) }
.toSet()
}

private fun map(
entry: MutableMap.MutableEntry<TAccountRecord, Result<TCustomerRecord>>
): Account {
val customers =
entry.value.map { record ->
Customer(
record.id?.toLong(),
record.orgid!!,
record.customerid!!,
record.firstname!!,
record.lastname!!,
emptyList(),
record.version?.toLong())
}
return entry.key.into(Account::class.java)!!.copy(customers = customers.toSet())
}

on java16 sfm raises NPE, while on java15 it works just fine:

java.lang.NullPointerException: Parameter specified as non-null is null: method com.edb.fs.tac.jfr.srv.model.account.Account.<init>, parameter accountNumber at com.edb.fs.tac.jfr.srv.service.account.AccountServiceIntegrationTest.testListAccount(AccountServiceIntegrationTest.kt:43)


apparently sfm isn't quite dead yet, https://twitter.com/davidkarlsen/status/1389295702438727680 - but there is not much going on.

Lukas Eder

unread,
May 24, 2021, 5:04:43 AM5/24/21
to jOOQ User Group
Hi David,

I understand, a month without a reply from Arnaud is quite some time, but then again, the reply you would have gotten until now (to your github issue) is probably just a simple "no, I haven't tested SFM on Java 16 yet", or "yes I have", none of which would get you any further.

In the meantime, if you could try to create an MCVE (e.g. using this template here https://github.com/jOOQ/jOOQ-mcve), I'm sure that could help speed things up for you. Maybe, the problem is really simple to reproduce for you after all if you can reduce your example to a minimum, complete verifiable example (MCVE).

It isn't easy to reproduce for anyone else, currently, keeping in mind that it arises from combining:

- jOOQ
- SFM
- Kotlin (with their language versions and stdlib versions)
- JDK versions

In your example, I don't see the SFM usage, so I couldn't tell either what the problem might be, or why you're using it for this particular example.

I understand that bugs arising from the combination of 4 technologies are annoying. You want to work on business logic, not this infrastructure logic and its quirks. However, the fastest way to get you back on track with what you actually want to do is to create MCVE's and report them to the product that produced the bug (might even be a jOOQ bug).

I hope this helps,
Lukas


Reply all
Reply to author
Forward
0 new messages