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

In v1.7.0, kotlin data class is no longer recognized as pojo #373

Open
yusukezzz opened this issue Aug 4, 2024 · 1 comment
Open

In v1.7.0, kotlin data class is no longer recognized as pojo #373

yusukezzz opened this issue Aug 4, 2024 · 1 comment
Labels

Comments

@yusukezzz
Copy link

My english is very poor, sorry.

Thank you for making great library!

I recently upgraded to v1.8.0 from v1.6.0 and noticed that the code that used kotlin data class as pojo stopped working.
This change seems to have occurred since v1.7.0.

sample project

Data Class Definition

data class User(val id: Int, val name: String)

v1.6.0 outputs

[User(id=1, name=foo), User(id=2, name=bar)]

but in v1.7.0

Exception in thread "main" org.sql2o.Sql2oException: Could not find parameter-less constructor of class class org.example.User
	at org.sql2o.reflection.ReflectionObjectConstructorFactory.newConstructor(ReflectionObjectConstructorFactory.java:24)
	at org.sql2o.reflection.FactoryFacade.newConstructor(FactoryFacade.java:80)
	at org.sql2o.reflection.PojoMetadata.initializePropertyInfo(PojoMetadata.java:99)
	at org.sql2o.reflection.PojoMetadata$Cache.evaluate(PojoMetadata.java:244)
	at org.sql2o.reflection.PojoMetadata$Cache.evaluate(PojoMetadata.java:241)
	at org.sql2o.tools.AbstractCache.get(AbstractCache.java:49)
	at org.sql2o.reflection.PojoMetadata.getPropertyInfoThroughCache(PojoMetadata.java:81)
	at org.sql2o.reflection.PojoMetadata.<init>(PojoMetadata.java:68)
	at org.sql2o.DefaultResultSetHandlerFactoryBuilder.newFactory(DefaultResultSetHandlerFactoryBuilder.java:61)
	at org.sql2o.Query.newResultSetHandlerFactory(Query.java:539)
	at org.sql2o.Query.executeAndFetch(Query.java:585)
	at org.example.MainKt.main(Main.kt:32)
	at org.example.MainKt.main(Main.kt)

Kotlin's data class is very useful and I want to use it as a POJO as before, is it possible to fix this behavior...?

@aaberg aaberg added the bug label Aug 5, 2024
@aaberg
Copy link
Owner

aaberg commented Aug 5, 2024

Hi @yusukezzz,

Thanks for reporting this. I need to investigate the issue, and then I will get back to you.

And, by the way, I think your English is quite good🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants