Introducing Easy-Query: A High‑Performance Java ORM with Fluent Query API
This article explains the motivation behind creating the Easy-Query ORM for Java, demonstrates its fluent query capabilities—including single‑record, list, pagination, joins, sub‑queries, group‑by, native SQL and dynamic condition features—provides extensive code examples, and shares repository links for further exploration.
After years of searching for a .NET‑style ORM that could handle most scenarios with strong‑typed syntax, the author found existing solutions like MyBatis‑Plus insufficient and decided to develop a new Java ORM inspired by the completeness and extensibility of .NET ORM ecosystems.
Easy‑Query offers a fluent API for building SQL queries, allowing operations such as retrieving the first record, asserting a single result, fetching multiple records, selecting specific columns, pagination, and converting expressions into nested sub‑queries.
Example of querying the first record:
Topic topic = easyQuery.queryable(Topic.class)
.where(o -> o.eq(Topic::getId, "123"))
.firstOrNull();Example of a paginated query:
EasyPageResult
pageResult = easyQuery
.queryable(Topic.class)
.where(o -> o.isNotNull(Topic::getId))
.toPageResult(1, 20);Easy‑Query also supports complex joins, sub‑queries, multi‑table left joins, and streaming large result sets for high‑performance data iteration.
// Multi‑table left join example
Topic topic = easyQuery
.queryable(Topic.class)
.leftJoin(BlogEntity.class, (t, t1) -> t.eq(t1, Topic::getId, BlogEntity::getId))
.where(o -> o.eq(Topic::getId, "3"))
.firstOrNull();Dynamic condition queries can be built from request objects, and results can be mapped to custom VO classes with column aliasing.
BlogQuery2Request query = new BlogQuery2Request();
query.setContent("标题");
List
list = easyQuery.queryable(BlogEntity.class)
.whereObject(query)
.toList();Additional features include native SQL fragments, database function columns, high‑performance encryption/decryption for LIKE patterns, data tracking, atomic updates, and sharding support, all without external dependencies and compatible with both Java and Kotlin.
Source code and documentation are available on GitHub and Gitee:
GitHub: https://github.com/dromara/easy-query
Gitee: https://gitee.com/xuejm/easy-query
Architecture Digest
Focusing on Java backend development, covering application architecture from top-tier internet companies (high availability, high performance, high stability), big data, machine learning, Java architecture, and other popular fields.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.