> 我说JPA+QueryDSL是最好的orm实现方案没人反对吧?
从开始使用jpa+QueryDSL之后所有话事的新项目和还未完成的老项目也都换成了这种方案来实现orm
因为真的很香!

6月16日17日 querydsl团队合并了QueryDSL 5 的pr,时隔9个月,QueryDSL也终于迎来了新的大版本,

本来想等等英语好的老哥翻译看看有啥新功能的,但是等不及了,配合蹩脚的英语和机翻,直接先吃!
以下来自官方github的release
- 传送门:[QUERYDSL_5_0_0_M1](https://github.com/querydsl/querydsl/releases/tag/QUERYDSL_5_0_0_M1)
## QueryDSL 5.0.0.M1
此版本的 QueryDSL 以最低支持Java8为目标,进行了各种改进,为现代 Java 生态做准备。
删除了 `joda-time:joda-time`、`com.google.guava:guava` 和 `com.google.code.findbugs:jsr305` 的运行时(runtime)依赖
因为QueryDSL项目大部分时间都没有得到维护,所以5.0也是大家期待已久的版本!我们将在该版本中优先解决在社区中被反复提出的历史遗留问题
非常感谢所有的贡献者牺牲了自己的休息时间做出贡献,使得这个版本成为了可能:
* **[@mp911de](https://github.com/mp911de)**, for working on the MongoDB Document API;
* **[@daniel-shuy](https://github.com/daniel-shuy)**, 解耦`querydsl-sql`与`joda-time:joda-time`;
* **[@heesuk-ahn](https://github.com/heesuk-ahn)**, 负责改进对Hibernate的支持和`JPASQLQuery`中的计数查询;
* **[@harshtuna](https://github.com/harshtuna)**, `querydsl-collections`的NullsLast排序;
* **[@kherrala](https://github.com/kherrala)**, **[@ridoo](https://github.com/ridoo)** and **[@NikitaKochkurov](https://github.com/NikitaKochkurov)**, `querydsl-spatial`的 JTS 和 GeoLatte 升级;
* **[@ridoo](https://github.com/ridoo)**, `HibernateDomainExporter`和`JPADomainExporter`的Spatial支持;
* **[@lpandzic](https://github.com/lpandzic)**, Java 15 records 的 codegen支持,一般改进迭代;
* **[@F43nd1r](https://github.com/F43nd1r)**, Kotlin 代码生成, Java 11 支持, 一般改进迭代和CI;
* **[@jwgmeligmeyling](https://github.com/jwgmeligmeyling)**, **[@Shredder121](https://github.com/Shredder121)**, **[@johnktims](https://github.com/johnktims)**, **[@idosal](https://github.com/idosal)** and **[@robertandrewbain](https://github.com/robertandrewbain)**.
#### New features
* [#2672](https://github.com/querydsl/querydsl/pull/2672) - 在Java8源码层面对性能和代码做了各种提升和改进
* [#2672](https://github.com/querydsl/querydsl/pull/2672) - 添加了返回`Stream<T>`的`Fetchable#stream()`。(笔:这个新功能还是蛮重要的)
Make sure that the returned stream is always closed to free up resources, for example using _try-with-resources_.
It does not suffice to rely on a terminating operation on the stream for this (i.e. `forEach`, `collect`).
* [#2324](https://github.com/querydsl/querydsl/issues/2324) - 移除Guava依赖项
Almost no required transitive dependencies to get started with QueryDSL.
And no more conflicts with Guava versions required by your other tools or own application.
* [#2025](https://github.com/querydsl/querydsl/issues/2025) - `joda-time:joda-time` 不再是 `querydsl-sql` 的必要依赖项.
By default, the Java 8 date/time API is used for date/time operations.
The `joda-time:joda-time` types will still be registered automatically if they are on the classpath.
* [#2215](https://github.com/querydsl/querydsl/issues/2215) - 通过文档API支持MongoDB 4
* [#2697](https://github.com/querydsl/querydsl/issues/2697) - 允许`com.querydsl.core.alias.Alias.*`依靠ECJ作为编译器,在JRE上使用。
* [#2479](https://github.com/querydsl/querydsl/issues/2479) - Swap out JSR305 for Jetbrains Annotations.
Because the Jetbrains Annotations, contrary to the JSR305 annotations, use a Class retention level, Jetbrains Annotations
does not have to be available at runtime and is not a transitive dependency.
* [#658](https://github.com/querydsl/querydsl/issues/658) - 增加了`JPAExpressions#treat`,可用于生成JPA 2.1的TreatedPath表达式。
* [#2666](https://github.com/querydsl/querydsl/issues/2666) - 在JPA中使用不支持的查询功能时,有更具体的错误信息。
* [#2106](https://github.com/querydsl/querydsl/issues/2106) - `querydsl-collections`实现了NullsLast排序.
* [#2404](https://github.com/querydsl/querydsl/issues/2404) - Upgrade of JTS / Geolatte in `querydsl-spatial`
* [#2320](https://github.com/querydsl/querydsl/issues/2320) - `HibernateDomainExporter` 和`JPADomainExporter`支持了Spatial
* [#2612](https://github.com/querydsl/querydsl/issues/2612) - 支持 Jakarta EE 新版本的 `jakarta.*` 包(available through the`jakarta` classifiers for Maven)
* [#1376](https://github.com/querydsl/querydsl/issues/1376) - Expression的函数`nullif`和`coalesce`返回的Expression有了具体返回类型(笔:打个比方就是Qxxx.fieldXX.nullif()函数)
* [#1828](https://github.com/querydsl/querydsl/issues/1828) - Kotlin Codegen支持
* [#2798](https://github.com/querydsl/querydsl/pull/2798) - Java Record 支持(笔:高版本的东西,Java14开始出现,Java8没有哈哈)
#### Bugfixes
* [#2579](https://github.com/querydsl/querydsl/issues/2579) - Count query generation in `JPASQLQuery`
* [#2671](https://github.com/querydsl/querydsl/issues/2671) - Fixed a concurrency issue in `Alias.*`. `Alias.*` is now Thread safe.
* [#2053](https://github.com/querydsl/querydsl/issues/2053) - Work around issues with `AbstractJPAQuery#fetchResults` and `AbstractJPAQuery#fetchCount` in a query with a having clause by using an in-memory calculation.
* [#2504](https://github.com/querydsl/querydsl/issues/2504) - Work around issues with `AbstractJPAQuery#fetchResults` and `AbstractJPAQuery#fetchCount` in a query with multiple group by expressions by using an in-memory calculation.
* [#2663](https://github.com/querydsl/querydsl/issues/2663) - Fix issues with the JPA implementation of `InsertClause`.
* [#2706](https://github.com/querydsl/querydsl/pull/2706) - Fix a memory leak in `TemplateFactory`.
* [#2467](https://github.com/querydsl/querydsl/issues/2467) - Prevent `ExtendedBeanSerializer` from generating `toString` method twice
* [#2326](https://github.com/querydsl/querydsl/issues/2326) - Use JPA indexed parameters instead of HQL's legacy positional parameters
* [#2816](https://github.com/querydsl/querydsl/issues/2816) - Generated JPA query with incorrect argument binding indexes
* [#1413](https://github.com/querydsl/querydsl/issues/1413) - Incorrect parameter values with Hibernate custom types
* [#1429](https://github.com/querydsl/querydsl/issues/1429) - Reusing of constants in JPQL generation causes issues with hibernate query caching
#### Breaking changes(破坏性更新)
* 最低支持Java8. 如果你使用Java7以下,请使用4.X.X版本的QueryDSL
* `JavaSE6SQLExceptionWrapper` and other parts regarding pre-Java 7 exception handling are removed.
* 删除了为了向后兼容传统API而设置的桥接方法。这可能会导致一些破坏性的API变化。
* 删除了依赖项Guava。如果您的应用程序依赖Guava,请确保将其添加为项目的直接依赖项,而不是依赖 QueryDSL 传递它。
* In order for Guava to be removed Mysema Codegen had to be rereleased as QueryDSL Codegen Utils.
Therefore, the classes in this module moved to a different package: `com.mysema.codegen` is now `com.querydsl.codegen.utils`.
This for example affects `com.mysema.codegen.model.SimpleType`.
Although many applications won't touch the codgen internal classes, custom APT extensions might be affected by this.
* 由于移除了 Guava,任何接收 `ImmutableList` 作为参数的方法现在都接受任何 `List`。
Normal code should handle this signature just fine.
However, make sure to check any reflective uses of these parameters.
* 用于`DefaultConfiguration`的`querydsl.variableNameFunctionClass`属性现在应该提供`java.util.function.Function`,而不是`com.google.common.base.Function`。
* `CodeWriter#beginStaticMethod`现在采用`java.util.function.Function`而不是`com.google.common.base.Function`.
* `AbstractLuceneQuery`现在采用`java.util.function.Function`而不是`com.google.common.base.Function`.
* `AbstractMongodbQuery`现在采用`java.util.function.Function`而不是`com.google.common.base.Function`.
* `com.querydsl.codegen.NamingFunction`, `EvaluatorFunction`, `DefaultVariableFunction`从继承`com.google.common.base.Function`改为继承`java.util.function.Function`.
* 任何需要传入`javax.inject.Provider`的构造函数,现在都需要一个`java.util.function.Supplier`来代替。在大多数情况下,你可以用`provider::get`代替这个参数
* 这个版本继承的Hibernate主要针对Hibernate5.2。如果你需要Hibernate 4方言的特定工作方法,请使用`HQLTemplates`而不是`Hibernate5Templates`。
* 删除了所有的弃用函数
* `joda-time:joda-time`现在是一个可选的依赖关系。如果你的应用程序也依赖了`joda-time:joda-time`,请确保将其作为直接依赖关系,而不是依靠QueryDSL来引入它。
* `com.google.code.findbugs:jsr305` is no longer a dependency. If your application currently relies on QueryDSL shipping JSR305 transitively, you should add JSR305 as a direct dependency to your project.(笔:同上,不翻译了)
* MDC keys现在使用下划线`_`而不是点`.`作为分隔符:querydsl.query现在是querydsl_query,querydsl.parameters是querydsl_parameters。
* Removal of `PolyHedralSurface` in `querydsl-spatial` and `querydsl-sql-spatial` due to the upgrade of `geolatte-geom`.
* `com.querydsl.apt.Extension` moved to `com.querydsl.codegen` and now resides in the `querydsl-codegen` module.
* `com.querydsl.apt.SpatialSupport` moved to `com.querydsl.spatial.apt.SpatialSupport` and now resides in the `querydsl-spatial` module.
* `com.querydsl.sql.codegen.SpatialSupport` moved to `com.querydsl.sql.spatial.SpatialSupport` and now resides in the `querydsl-sql-spatial` module.(笔:同上,一些模块上的变化)
* `SQLServerGeometryReader` in `querydsl-sql-spatial` is removed in favour of `org.geolatte.geom.codec.db.sqlserver.*`.
* `PGgeometryConverter` in `querydsl-sql-spatial` is removed in favour of `org.geolatte.geom.codec.Wkt`.
* `JGeometryConverter` in `querydsl-sql-spatial` is removed in favour of `org.geolatte.geom.codec.db.oracle.*`.(笔:同上,querydsl-sql-spatial的一些XX代替了一些XX)
* 删除了`querysql-jpa-codegen`中的`HibernateDomainExporter`。`HibernateDomainExporter`只支持Hibernate 4,而QueryDSL不再积极支持Hibernate。相反,使用Hibernate和JPADomainExporter。
* `ComparableExpression#coalesce`(和其子类型)不再返回mutable的`Coalesce Expression`,而是返回一个具体类型(typed)的Expression。
如果您需要 `Coalesce builder`,请改用 `new Coalesce<T>().add(expression)`。
* `getConstantToNamedLabel`、`getConstantToNumberedLabel`和`getConstantToAllLabels`是在`SerializerBase`和`JPQLSerializer`中临时引入的,用于最终取代 QueryDSL 4.3.0的`getConstantToLabel`。
现在`getConstantToLabel`已被删除,转而使用`getConstants`。
#### Deprecations (弃用)
* `AbstractJPAQuery#fetchResults`和`AbstractJPAQuery#fetchCount`现在已经不再适用于有多个`group by`表达式或有子句的查询,因为这些情况不能由纯JPA支持,而是在内存中来计算的。
如果不需要计算结果的总数,我们建议使用`AbstractJPAQuery#fetch`来代替。
如果你想要一个即便复杂但是可靠的方法来计算分页结果的数量,我们建议使用[Blaze-Persistence QueryDSL integration](https://persistence.blazebit.com/documentation/1.5/core/manual/en_US/#querydsl-integration)。
`BlazeJPAQuery`正确地实现了`fetchResults`和`fetchCount`,甚至还带有`page`方法。
* `getConstantToLabel` which was deprecated in QueryDSL 4.3.0 is no longer deprecated.(笔:上面破坏性更新说了)
#### Dependency updates (依赖升级)
* `cglib:cglib` to 3.3.0 for Java 8+ support
* `org.eclipse.jdt.core.compiler:ecj` to 4.6.1 for Java 8+ support
* `joda-time:joda-time` to 2.10.10 for better interoperability with other frameworks that use more recent versions than QueryDSL.
`joda-time:joda-time` is also no longer a required dependency and as such is no longer provided transitively to your application.
If your application relies on `joda-time:joda-time` being available, make sure to add the dependency to your project.
* `org.geolatte:geolatte-geom` to 1.8.1 for better interopability with Hibernate Spatial.
`querydsl-spatial` is still backwards compatible with older versions of Geolatte, however, `querydsl-sql-spatial` is not and requires 1.4.0 or newer.
* `com.vividsolutions:jts` to `org.locationtech:jts` for better interopability with Hibernate Spatial.
`com.vividsolutions:jts` is still supported for `querydsl-spatial` if an older version of `org.geolatte:geolatte-geom` is provided.
* DataNucleus 5.2.x for Java 8+ support
* JDO now uses `org.datanucleus:javax.jdo` instead of `javax.jdo:jdo-api`
* `com.google.guava:guava` is no longer a dependency of QueryDSL and as such is no longer provided transitively to your application.
If your application relies on `com.google.guava:guava` being available, make sure to add the dependency to your project.
* `com.google.code.findbugs:jsr305` is no longer a dependency of QueryDSL and as such is no longer provided transitively to your application.
If your application relies on `com.google.code.findbugs:jsr305` being available, make sure to add the dependency to your project.
以上
有很多地方可能翻译有错误,希望大家指出🖖
有部分翻译,比如bugfix和依赖升级的地方我没有做翻译,因为翻译起来难度很大(我是废物!),有遇到bug的小伙伴可能也不需要我的翻译,直接就看到了,所以没有翻译👐
翻译的过程虽然比较消耗精力,但是可以很好地了解一个项目的更新内容和方向,还是很快乐的💖

QueryDSL 5.0 快照已发布,久等了!