-
Notifications
You must be signed in to change notification settings - Fork 227
How to use Kotlin data class in v1.7.0 or later? #373
Copy link
Copy link
Closed
Labels
Description
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.
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...?
Reactions are currently unavailable