javaer 们, JPA 和 mybatis,喜欢用哪一个

2020 年 9 月 25 日
 tsingke

mybatis 新出了 https://github.com/mybatis/mybatis-dynamic-sql 简单查询用起来很爽。

13263 次点击
所在节点    程序员
92 条回复
tohuer00
2020 年 9 月 26 日
我在想是不是现在的小朋友都不会写 sql 了 所以 jpa 这种东西才会这么热
jeffh
2020 年 9 月 26 日
mybatis plus
tydl
2020 年 9 月 26 日
PHP 是最好的语言~~~~~~~
tsingke
2020 年 9 月 26 日
@tydl 兄弟 时代变了 php 要黄了
yinzhili
2020 年 9 月 26 日
一开始功能简单的时候 jpa 可以节省开发时间,但我觉得如果项目规模慢慢扩大,对于复杂的报表需求又不得不用 mybatis 。所以为什么不干脆一开始就选用 mybatis 呢?
xuanbg
2020 年 9 月 26 日
@sagaxu
@a719031256

现在都是这种注解写法吧……

@Results({@Result(property = "detail", column = "detail", javaType = Object.class, typeHandler = JsonTypeHandler.class)})
@Select("<script>select a.id, e.`name` as entity, a.type, a.`code`, a.`name`, a.balance, a.detail, a.is_invalid " +
"from iaf_account a join iab_entity e on e.id = a.entity_id where e.tenant_id = #{tenantId} " +
"<if test = 'key != null'>and (type = #{type} or `code` = #{key} or name like concat('%',#{key},'%')) </if>" +
"order by created_time desc</script>")
List<AccountDto> getAccounts(QueryDto dto);

压根不需要 xml
anguiao
2020 年 9 月 26 日
@xuanbg 对 mybatis 来说,没觉得注解和 xml 比起来有什么优势。
KV2
2020 年 9 月 26 日
jpa+jdbcTemplate
rb6221
2020 年 9 月 26 日
我写过一个项目挺复杂,用的 jdbc
securityCoding
2020 年 9 月 26 日
jpa
18258226728
2020 年 9 月 26 日
mybatis-plus,啥也不想,小项目也用这个,总是会出现 sql jpa 搞不了
MarioLuo
2020 年 9 月 26 日
项目用的 spring-data-mongo, 其中 CRUD 方法、分页排序、方法名的查询、注解条件甚是方便、SpringData 系列互通,人生苦短何不一试。
xe2vherd
2020 年 9 月 26 日
我选择 SQlAchemey...
MarioLuo
2020 年 9 月 26 日
@rockyou12 query dsl 代码生成每次都需要手动触发 compile, 这个怎么弄?而且为了少数查询需求生成这么多代码感觉有点重
rockyou12
2020 年 9 月 26 日
@MarioLuo 我写的时候反正没有需要 compile 的问题,可能因为我项目都是用的 gradle……
wangyanrui
2020 年 9 月 26 日
简而言之,面相对象和面相过程的 PK
简单业务逻辑,写到 service 中,选哪个无所谓
复杂业务逻辑,想要 ddd,选 jpa🙄
chenhui7373
2020 年 9 月 26 日
@18258226728 印象可以这样?@Query(native=true,value="SQL_PLACEHOLDER")
chenhui7373
2020 年 9 月 26 日
r2dbc 貌似 jpa 友好
yalin
2020 年 9 月 26 日
jpa
yalin
2020 年 9 月 26 日
微服务的 cqrs 架构

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://study.congcong.us/t/710385

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX