RepoPilot

How do their APIs compare?

About mybatis/mybatis-3 · 2 messages · last activity 8/16/2026

Question

How do their APIs compare?

RepoPilot

Since these two projects serve very different purposes, "API comparison" mostly makes sense in terms of design philosophy and surface shape rather than feature-for-feature parity. Here's how they compare based on what's in the retrieved data:

mybatis/mybatis-3: annotation- and configuration-driven mapping API

MyBatis's public API is largely built around annotations that declare SQL bindings on interface methods, plus an underlying SQL-source/configuration layer:

  • Statement annotations like @Select, @InsertProvider, @DeleteProvider, @UpdateProvider, @SelectProvider let you either embed SQL directly or delegate to a provider method. For example, @Select is documented with a simple usage pattern binding a method directly to SQL [src/main/java/org/apache/ibatis/annotations/Select.java:L24-L40].
  • The *Provider annotations (InsertProvider, DeleteProvider, UpdateProvider, SelectProvider) share a consistent API pattern: a type() attribute naming a provider class, and an optional method() attribute that can be omitted since 3.5.1 if the type implements ProviderMethodResolver, falling back to a conventionally named provideSql method otherwise [src/main/java/org/apache/ibatis/annotations/InsertProvider.java:L71-L100], [src/main/java/org/apache/ibatis/annotations/SelectProvider.java:L71-L100]. This is a deliberate convention-over-configuration API design repeated across all four provider annotations.
  • SelectProvider additionally exposes an affectData() flag (since 3.5.12) for statements that mutate data despite being a "select" (e.g., RETURNING/OUTPUT clauses) [src/main/java/org/apache/ibatis/annotations/SelectProvider.java:L100-L110].
  • Below the annotation layer, mapping is resolved into SqlSource implementations such as StaticSqlSource, which is a low-level internal API consumed by the mapper-building pipeline, not typically touched by end users directly [src/main/java/org/apache/ibatis/builder/StaticSqlSource.java:L1-L27].
  • Result mapping has its own annotation API, e.g. @Many for nested collection results, referencing @Result/@Results [src/main/java/org/apache/ibatis/annotations/Many.java:L24-L40].

So MyBatis's API surface is declarative and reflection/annotation-heavy, oriented around mapping Java interfaces to SQL execution, with a layered internal builder/session API underneath.

stleary/json-java: object-graph and pointer-query API

json-java's API is much smaller in conceptual scope — it's about constructing, representing, and querying JSON data structures in memory:

  • JSONObject supports bean-style reflective construction, turning getter methods into JSON keys/values, with @JSONPropertyName to override generated key names [src/main/java/org/json/JSONObject.java:L397-L436]. This is somewhat analogous in spirit to MyBatis's annotation-driven mapping, but here it's Java-object-to-JSON rather than Java-method-to-SQL.
  • JSONPointer implements RFC 6901 pointer syntax, with a Builder inner class for programmatically constructing pointers token-by-token (JSONPointer.builder().append(...).build()) [src/main/java/org/json/JSONPointer.java:L34-L73].
  • Both JSONObject and JSONArray expose parallel query(String) / query(JSONPointer) (and optQuery) methods that resolve a pointer against the structure, throwing JSONPointerException on invalid paths or returning null for the opt variants [src/main/java/org/json/JSONArray.java:L1583-L1622].

So json-java's API is a data-structure query/traversal API, much narrower than MyBatis's, focused on JSON parsing, construction, and pointer-based lookup rather than any persistence or SQL-binding concerns.

Key contrasts

Aspectmybatis-3json-java
Core abstractionSQL statement bound to a Java method via annotations/XMLIn-memory JSON tree (JSONObject/JSONArray)
Extension m

Want to ask your own question?

Open chat for mybatis/mybatis-3

Public 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.