Mapper.xml can support the dynamic creation of SQL, but is there a better way to use it? For example, creating SQL using a DSL? ``` package top.rish; import java.util.List;

import static top.rish.Order.ORDER; import static top.rish.User.USER; import static top.rish.jsql.dsl.Dsl.*; public class Ztest { public static void main(String[] args) { List query = sql( select() ,from( USER.as("u").leftJoinOn(ORDER.as("o"),USER.ID.eq(ORDER.USER_ID)) ) ,where( USER.ID.eq(1) ) ,orderBy(USER.ID) ,groupBy(USER.ID) ,limit(0,10) ).query(User.class); // sql: select * from user as u left join order as o on u.id = o.user_id where u.id = 1 order by u.id desc group by u.id limit 0 , 10 System.out.println(query); // [User(id,userName,....),User(id,userName,....),.......] } } ```

select * from user as u left join order as o on u.id = o.user_id where u.id = 1 order by u.id desc group by u.id limit 0 , 10

Comment From: itdoer

If you implement orm using DSL,mybatis will really be perfect

Comment From: itdoer

This is just an example of what I've done by hand, and the idea behind it, to you, should be fairly simple, but the object relational mapping behind it is more central, so why not try a DSL?

Comment From: harawata

Hi @itdoer , Check out https://github.com/mybatis/mybatis-dynamic-sql

Comment From: harawata

No response.