Skip to content

Fix: add proper backwards-compatible Kotlin support - #42

Merged
lpandzic merged 2 commits into
infobip:masterfrom
dirkluijk:add-proper-kotlin-support
Sep 15, 2021
Merged

lpandzic merged 2 commits into
infobip:masterfrom
dirkluijk:add-proper-kotlin-support

Conversation

@dirkluijk

@dirkluijk dirkluijk commented Sep 15, 2021

Copy link
Copy Markdown
Contributor

Fixes #11

In #37, I added support for Kotlin classes by using PreferredConstructorDiscoverer from Spring Data Common.

However, Spring prefers no-argument constructors over other constructors, which doesn't seem to be compatible with QueryDSL. Therefore, the original implementation preferred the constructor with the most parameters instead.

To be compatible with both QueryDSL and Kotlin data classes, I made a custom PreferredConstructorDiscoverer which is inspired by the way Spring Data Common supports Kotlin, but still uses the custom logic that was implemented before.

Comment thread infobip-spring-data-common/pom.xml
Comment thread infobip-spring-data-common/pom.xml
@lpandzic
lpandzic merged commit 989cb6e into infobip:master Sep 15, 2021
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<optional>true</optional>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS I suspect that this can't be optional due to the fact that kotlin discovery code path is invoked every time, even in non kotlin environments?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Spring Data Common it's optional, I think because we first invoke KotlinReflectionUtils. isSupportedKotlinClass from Spring, which - I think - doesn't rely on kotkin-reflect itself.

@dirkluijk
dirkluijk deleted the add-proper-kotlin-support branch September 15, 2021 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

repository.findAll(Predicate) produce SQL Syntax error.

2 participants