How do their APIs compare?
How do their APIs compare?
About mybatis/mybatis-3 · 2 messages · last activity 8/15/2026
This is a bit of an apples-to-oranges comparison since these two projects solve very different problems, but let's compare their API surfaces based on what's in the retrieved data.
mybatis/mybatis-3: SQL-mapping API
MyBatis's public API is dominated by declarative annotations that map Java interface methods to SQL statements. Key patterns visible in the data:
- Statement annotations:
@Select, with variants like@SelectProvider,@InsertProvider,@UpdateProvider,@DeleteProvider— these let you either embed SQL directly (@Select("SELECT id, name FROM users WHERE id = #{id}")in [src/main/java/org/apache/ibatis/annotations/Select.java:L27-L39]) or delegate SQL generation to a provider class/method (@SelectProvider(type = SqlProvider.class, method = "selectById")in [src/main/java/org/apache/ibatis/annotations/SelectProvider.java:L31-L40]). - Provider resolution convention: All the
*Providerannotations (InsertProvider,DeleteProvider,UpdateProvider,SelectProvider) share an identicalmethod()/databaseId()contract and fallback resolution logic viaProviderMethodResolveror aprovideSqlmethod — see [src/main/java/org/apache/ibatis/annotations/InsertProvider.java:L75-L90], [src/main/java/org/apache/ibatis/annotations/DeleteProvider.java:L75-L90], [src/main/java/org/apache/ibatis/annotations/UpdateProvider.java:L75-L88], [src/main/java/org/apache/ibatis/annotations/SelectProvider.java:L44-L59]. - Result mapping annotations:
@Results/@Resultlet you declaratively bind columns to properties, including nested associations/collections via@One/@Manywith lazy fetch types, as shown in [src/main/java/org/apache/ibatis/annotations/Results.java:L27-L40]. - Internal SQL representation: Underneath the annotation API,
StaticSqlSource(implementsSqlSource) represents a finalized, parameter-bound SQL string used at execution time — [src/main/java/org/apache/ibatis/builder/StaticSqlSource.java:L16-L26].
So MyBatis's API is fundamentally interface-and-annotation driven, oriented around mapping method signatures to SQL execution and result hydration. It's a synchronous, blocking, ORM-adjacent API.
spring-cloud-gateway: reactive HTTP routing/proxying API
Gateway's API is built around filters, routes, and reactive exchanges in a webflux (and webmvc) style:
- GlobalFilter implementations: Classes like
ForwardRoutingFilter[spring-cloud-gateway-server-webflux/.../ForwardRoutingFilter.java:L36-L77] andFunctionRoutingFilter[.../FunctionRoutingFilter.java:L66-L145] implementGlobalFilterandOrdered, intercepting aServerWebExchangeand returning aMono<Void>. These filters inspect the request URI scheme ("forward","fn") to decide whether to act or pass through viachain.filter(exchange). - ProxyExchange builder API: Both the WebFlux (
spring-cloud-gateway-proxyexchange-webflux/.../ProxyExchange.java:L54-L115) and WebMVC (spring-cloud-gateway-proxyexchange-webmvc/.../ProxyExchange.java:L81-L120) variants expose a fluent, builder-style API (.uri(...),.get(),.post(),.header(...)) injected as a controller method argument — this is a very different paradigm from MyBatis's annotation-driven interfaces; it's imperative/fluent Java used inside@RequestMappinghandler methods. - Configuration-driven autoconfiguration: Classes like
SimpleUrlHandlerMappingGlobalCorsAutoConfiguration[.../SimpleUrlHandlerMappingGlobalCorsAutoConfiguration.java:L1-L34] use Spring Boot's@ConditionalOnClass/
Want to ask your own question?
Open chat for mybatis/mybatis-3Public Q&A. Generated by RepoPilot from the actual source of mybatis/mybatis-3. AI answers can be incomplete or stale — verify before relying on them.