spring-projects / spring-data-relational

Spring Data Relational. Home of Spring Data JDBC and Spring Data R2DBC.
https://spring.io/projects/spring-data-jdbc
Apache License 2.0
737 stars 339 forks source link

Using immutables @Value.Default causes failure in instantiating immutable #1819

Closed hpalma closed 3 weeks ago

hpalma commented 3 weeks ago

I'm using immutable.io and the converter configuration exactly as exemplified here.

This works fine, but if i add a @Value.Default to my domain class, like:

@Value.Default
default Integer getNumberOfStudents() {
   return 0;
}

I start getting the following error:

java.lang.NoSuchMethodException: org.myapp.ImmutableDomainClass.<init>()

I've found that this is because when you add @Value.Default immutables actually generates a second constructor that receives the Builder as parameter. Because of this then the spring converter is not able to select which constructor to use (because it finds 2) and just fails to initialize.

schauder commented 3 weeks ago

So your ask is to support @Value.Default?

hpalma commented 3 weeks ago

So your ask is to support @Value.Default?

Yes, that sums it up :)

schauder commented 3 weeks ago

We are currently not aiming at full support for immutable.io. The example is just that: an example what is currently possible. We are there not going to extend support ot @Value.Default or similar.