java/kotlin high performance lightweight solution for jdbc query,support oltp and olap query,一款java下面支持强类型、轻量级、高性能的ORM,致力于解决jdbc查询,拥有对象模型筛选、隐式子查询、隐式join
java/kotlin high performance lightweight solution for jdbc query,support oltp and olap query,一款java下面支持强类型、轻量级、高性能的ORM,致力于解决jdbc查询,拥有对象模型筛选、隐式子查询、隐式join
全项目基于.Net专业团队自研,源头工厂,价格约是官方的二十分之一不到,获得全网数万用户好评,稳定安全,快速可靠!
用Ai就选择意心Ai,省心放心爽用!让你不再有Ai焦虑!
https://github.com/wzszsw/easy-query-orm
Company OneToMany SysUser
List userInXXCompany = entityQuery.queryable(SysUser.class)
.where(user -> {
user.company().name().like("xx Company");
})
.orderBy(user -> {
user.company().registerMoney().desc();
user.birthday().asc();
}).toList();
List companies = entityQuery.queryable(Company.class)
.where(company -> {
company.users().any(u -> u.name().like("Xiao Ming"));
company.users().where(u -> u.name().like("Xiao Ming"))
.max(u -> u.birthday()).gt(LocalDateTime.of(2000,1,1,0,0,0));
}).toList();
List companies = entityQuery.queryable(Company.class)
// Two subqueries in where will be merged
.subQueryToGroupJoin(company -> company.users())
.where(company -> {
company.users().any(u -> u.name().like("Xiao Ming"));
company.users().where(u -> u.name().like("Xiao Ming"))
.max(u -> u.birthday()).gt(LocalDateTime.now());
}).toList();
List companies = entityQuery.queryable(Company.class)
.where(company -> {
company.users().orderBy(u->u.birthday().desc()).first().name().eq("Xiao Ming");
company.users().orderBy(u->u.birthday().desc()).element(0)
.birthday().lt(LocalDateTime.now());
}).toList();
…
First, let's look at a complete single-table query example involving filtering, aggregation, aggregate filtering, projection, and sorting.
…
easy-query is a high-performance, lightweight, and versatile Java/Kotlin object query ORM framework that supports database sharding and read-write separation.
easy-query is a dependency-free JAVA/Kotlin ORM framework, extremely lightweight, with high performance. It supports single table queries, multi-table queries, union, subqueries, pagination, dynamic table names, VO object query returns, logical deletion, global interception, database column encryption (supporting high-performance LIKE queries), data tracking for differential updates, optimistic locking, multi-tenancy, automatic database sharding, automatic table sharding, read-write separation, and supports full-featured external extension customization of the framework, with strong-typed expressions.
https://central.sonatype.com/ search com.easy-query获取最新Installation包
…
for mysql
last-version
com.easy-query
sql-api-proxy
${easy-query.version}
com.easy-query
sql-mysql
${easy-query.version}
…
sql script
…
query entity
…
Topic topic = easyEntityQuery
.queryable(Topic.class)
.where(o -> o.id().eq("3"))
.firstOrNull();
==> Preparing: SELECT t.`id`,t.`stars`,t.`title`,t.`create_time` FROM `t_topic` t WHERE t.`id` = ? LIMIT 1
==> Parameters: 3(String)
t.id().eq(t1.id()))
.where(o -> {
o.id().eq("3");
o.title().eq("4");
})
.firstOrNull();
…
==> Preparing: SELECT COUNT(*) FROM (SELECT t1.`id` AS `id`,SUM(t1.`score`) AS `score` FROM `t_topic` t INNER JOIN `t_blog` t1 ON t1.`deleted` = ? AND t.`id` = t1.`id` WHERE t1.`title` IS NOT NULL GROUP BY t1.`id`) t2
==> Parameters: false(Boolean)
Preparing: SELECT t1.`id` AS `id`,SUM(t1.`score`) AS `score` FROM `t_topic` t INNER JOIN `t_blog` t1 ON t1.`deleted` = ? AND t.`id` = t1.`id` WHERE t1.`title` IS NOT NULL GROUP BY t1.`id` LIMIT 20
==> Parameters: false(Boolean)
"aa_bb_cc")
.where(o -> o.id().eq("123"))
.toList();
SELECT t.`id`,t.`create_time`,t.`update_time`,t.`create_by`,t.`update_by`,t.`deleted`,t.`title`,t.`content`,t.`url`,t.`star`,t.`publish_time`,t.`score`,t.`status`,t.`order`,t.`is_top`,t.`top` FROM `aa_bb_cc` t WHERE t.`deleted` = ? AND t.`id` = ?
Topic topic = new Topic();
topic.setId(String.valueOf(0));
topic.setStars(100);
topic.setTitle("标题0");
topic.setCreateTime(LocalDateTime.now().plusDays(i));
long rows = easyEntityQuery.insertable(topic).executeRows();
//返回结果rows为1
==> Preparing: INSERT INTO `t_topic` (`id`,`stars`,`title`,`create_time`) VALUES (?,?,?,?)
==> Parameters: 0(String),100(Integer),标题0(String),2023-03-16T21:34:13.287(LocalDateTime)
o.id().eq("7")).firstNotNull("未找到对应的数据");
String newTitle = "test123" + new Random().nextInt(100);
topic.setTitle(newTitle);
long rows=easyEntityQuery.updatable(topic).executeRows();
…
==> Preparing: UPDATE t_topic SET `stars` = ? WHERE `id` = ?
==> Parameters: 12(Integer),2(String)
o.title().eq("title998"))
.executeRows();
==> Preparing: DELETE FROM t_topic WHERE `title` = ?
==> Parameters: title998(String)
Preparing: DELETE FROM t_topic WHERE `id` = ?
==> Parameters: 997(String)
q1 = easyQuery
.queryable(Topic.class);
Queryable q2 = easyQuery
.queryable(Topic.class);
Queryable q3 = easyQuery
.queryable(Topic.class);
List list = q1.union(q2, q3).where(o -> o.eq(Topic::getId, "123321")).toList();
…
==> Preparing: SELECT t.`id`,t.`stars`,t.`title`,t.`create_time` FROM `t_topic` t WHERE t.`id` IN (SELECT t1.`id` FROM `t_blog` t1 WHERE t1.`deleted` = ? AND t1.`id` = ?)
==> Parameters: false(Boolean),1(String)
o.id().eq("1" ));
List list2 = easyEntityQuery.queryable(Topic.class)
.where(o -> {
o.exists(() -> where.where(q -> q.id().eq(o.id())));
}).toList();
…
其中shardingInitializer为Sharding初始化器用来初始化告诉框架有多少Sharding的表名(支持动态添加)
ShardingTableKey表示哪个字段作为Sharding键(Sharding键不等于主键)
执行sql
LocalDateTime beginTime = LocalDateTime.of(2021, 1, 1, 1, 1);
LocalDateTime endTime = LocalDateTime.of(2021, 5, 2, 1, 1);
Duration between = Duration.between(beginTime, endTime);
long days = between.toDays();
List list = easyQuery.queryable(TopicShardingTime.class)
.where(o->o.rangeClosed(TopicShardingTime::getCreateTime,beginTime,endTime))
.orderByAsc(o -> o.column(TopicShardingTime::getCreateTime))
.toList();
…
LocalDateTime beginTime = LocalDateTime.of(2020, 1, 1, 1, 1);
LocalDateTime endTime = LocalDateTime.of(2023, 5, 1, 1, 1);
Duration between = Duration.between(beginTime, endTime);
long days = between.toDays();
EasyPageResult pageResult = easyQuery.queryable(TopicShardingDataSource.class)
.orderByAsc(o -> o.column(TopicShardingDataSource::getCreateTime))
.toPageResult(1, 33);
…
个人QQ:326308290(欢迎技术支持提供您宝贵的意见)
个人邮箱:[email protected]
No open issues yet, or sync has not completed.