Search code examples
ibatiscriteria-apimybatisquerydsl

Is there any functionality similar to Criteria API in MyBatis, or any wrapper like QueryDSL to provide that functionality over it?


In JPA/Hibernate, we can write type-safe queries and accumulate our query predicates one step at a time. I believe that there is no equivalent of that in MyBatis, but is there any abstraction framework (like QueryDSL) that provides a layer above MyBatis, that can enable us to write criteria-like queries. My basic reason for wanting the criteria API is that I need to construct a query, each of whose predicates come from a separate logic.


Solution

  • You can use MBG (MyBatis Generator) with example classes.

    Though I doubt that the example classes are as powerful as Hibernate's Criteria Queries, they should suit well your task of constructing queries.