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
772 stars 346 forks source link

Improve SelectBuilder to require less casting #957

Open schauder opened 3 years ago

schauder commented 3 years ago

Using the SelectBuilder often requires casting because type information is lost in the API.

One example: https://github.com/spring-projects/spring-data-jdbc/blob/79923b66dc67f49a294a68eeab82a76b5dfaddc1/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/JdbcCountQueryCreator.java#L53

We should try to improve the API to require less casting.

mateskarayol commented 2 years ago

Hi @schauder, I want to work on this issue. I made a quick review for the issue. I think related extends should be added in SelectBuilder interface and then related implementations should be added to DefaultSelectBuilder class. Then all casting would be unnecessary. If this issue has any other aspect except above, may you state it, please ? Regards,

schauder commented 2 years ago

There are two things I'm currently aware of that we need to look out for.

  1. Backward compatibility. It would be nice if we can do the change in a backward compatible way, i.e. usage of the code don't need to change. If we can't maintain backward compatibility we can only introduce the change with 3.x which wouldn't be to bad either.
  2. It might be that methods that are only intended to be called once, after this change might get called multiple times. If this is the case we must make sure we have a consistent way to handle this. Just using the last call is probably fine.