spring-projects / sts4

The next generation of tooling for Spring Boot, including support for Cloud Foundry manifest files, Concourse CI pipeline definitions, BOSH deployment manifests, and more... - Available for Eclipse, Visual Studio Code, and Theia
https://spring.io/tools
Eclipse Public License 1.0
881 stars 205 forks source link

Better SQL experience #561

Closed MahatmaFatalError closed 1 year ago

MahatmaFatalError commented 4 years ago

Beforehand: This is not a concrete feature request but a request to start a discussion.

SQL queries are an essential part of many spring boot applications. However, the IDE experience for writing queries is far from good.

I see two major cases:

  1. SQL string literals (or JEP378 Text Blocks) for simple, static cases used with Spring Data @Query or JdbcTemplate
  2. Generated queries for quite complex and dynamic cases. Imperatively plumbing Strings with SQL fragments in Java is quite ugly. Libs like jooq, JPA Criteria API, MyBatis Dynamic SQL or QueryDSL provide a fluent Java API for composing SQL, but I personally favor MyBatis XML mappers due to better readability and broad feature set. I am aware of similar options like JDBI with StringTemplate but I have no experience with it.

For the static ones, there is basically no IDE support that early prevents errors, be it basic SQL syntax checks or more sophisticated schema validation. For dynamic queries, there is a special MyBatis XML Mapper Editor https://github.com/mybatis/mybatipse which at least improves the way to deal with MyBatis-specific things but still lacks SQL validation. Even preliminary syntax highlighting does not see much progress https://github.com/mybatis/mybatipse/issues/73

What I would like is a functionality for string literals to format, check the syntax based on a chosen SQL dialect and validate against entity classes or a live DB connection or DDL schema file. This configuration would be part of the project metadata.
For dynamic queries basically the same feature set, while this obviously highly depends on the concrete framework.

martinlippert commented 1 year ago

Hey @MahatmaFatalError , this issue is sitting here with not much attention for a long time already, so I don't really see us diving into a concrete discussion on this topic. I can understand the problem that you describe, but support for this is probably something that should be discussed somewhere else where a lot more people form the SQL space hang out and discuss general tooling for SQL.

MahatmaFatalError commented 1 year ago

jup, understandable