Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: add proper backwards-compatible Kotlin support #42

Merged
merged 2 commits into from
Sep 15, 2021

Conversation

dirkluijk
Copy link
Contributor

@dirkluijk dirkluijk commented Sep 15, 2021

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.

@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
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
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