简体   繁体   中英

Decouple SQL files and API models

Making use of the @BindBean annotation. SQL files reference fields by their name, and if one of these public facing field names is changed then the sql will need updated. However IDEs don't understand the context of the sql bound fields, so will not automatically change the sql during rename. To save from future error I would like to avoid this.

Below is an example of how BindBean is being used is any alternative possible . Which will not involve single binds to each of the objects values.

@SqlUpdate("create-something/createSomething")
Long createSomething(
        @Bind("somethingId") Long somethingId,
        @BindBean("somethingElse") SomethingElse somethingElse
);

I am not aware of any IDE support that understands the relationship between eg .stg.sql files and SQL objects.

IntelliJ can do deep text search on property rename, however I often find it to be overkill--eg renaming any field named id or name will turn up potentially thousands of cases of those tokens.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM