This release of QueryDSL targets Java 8 minimally and comes with various improvements to make QueryDSL ready for the modern Java ecosystem.
This version also removes joda-time:joda-time, com.google.guava:guava and com.google.code.findbugs:jsr305 as required runtime dependencies for using QueryDSL.
QueryDSL 5.0 is the long awaited major release after the QueryDSL project was left mostly unmaintained for over two years. With this release the team worked hard on resolving the most pressing issues that have been requested repeatedly for a long time.
A huge thanks goes out to all contributors that made this release possible in their free time:
- @mp911de, for working on the MongoDB Document API;
- @daniel-shuy, for working on decoupling
querydsl-sqlfromjoda-time:joda-time; - @heesuk-ahn, for working on improved Hibernate support and count query generation in
JPASQLQuery; - @harshtuna, for working on NullsLast ordering in
querydsl-collections; - @kherrala, @ridoo and @NikitaKochkurov for working on the JTS and GeoLatte upgrade for
querydsl-spatial; - @ridoo, for working on Spatial support in
HibernateDomainExporterandJPADomainExporter; - @lpandzic, for working on codegen support for Java 15 records and general improvements;
- @F43nd1r, for working on Kotlin Code generation, Java 11 support, general improvements and Continuous Integration;
- @jwgmeligmeyling, @Shredder121, @johnktims, @idosal and @robertandrewbain.
- #2672 - Various performance and code improvements possible by targeting Java 8 source level.
- #2672 - Added
Fetchable#stream()which returns aStream<T>. 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 - Removal of Guava as dependency. 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 -
joda-time:joda-timeis no longer a required dependency forquerydsl-sql. By default, the Java 8 date/time API is used for date/time operations. Thejoda-time:joda-timetypes will still be registered automatically if they are on the classpath. - #2215 - MongoDB 4 support through the Document API
- #2697 - Allow
com.querydsl.core.alias.Alias.*to be used on a JRE by relying on ECJ as compiler - #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 - Added
JPAExpressions#treatwhich can be used to generate JPA 2.1 Treated path expressions. - #2666 - More descriptive error message when using unsupported query features in JPA.
- #2106 - Support NullsLast ordering in
querydsl-collections. - #2404 - Upgrade of JTS / Geolatte in
querydsl-spatial - #2320 - Make Spatial support available to
HibernateDomainExporterandJPADomainExporter. - #2612 - Support jakarta.* packages for new Jakarta EE releases (available through the
jakartaclassifiers for Maven) - #1376 - Return typed expression from
nullifandcoalescemethods. - #1828 - Kotlin Codegen support
- #2798 - Java Record support
- #2579 - Count query generation in
JPASQLQuery - #2671 - Fixed a concurrency issue in
Alias.*.Alias.*is now Thread safe. - #2053 - Work around issues with
AbstractJPAQuery#fetchResultsandAbstractJPAQuery#fetchCountin a query with a having clause by using an in-memory calculation. - #2504 - Work around issues with
AbstractJPAQuery#fetchResultsandAbstractJPAQuery#fetchCountin a query with multiple group by expressions by using an in-memory calculation. - #2663 - Fix issues with the JPA implementation of
InsertClause. - #2706 - Fix a memory leak in
TemplateFactory. - #2467 - Prevent
ExtendedBeanSerializerfrom generatingtoStringmethod twice - #2326 - Use JPA indexed parameters instead of HQL's legacy positional parameters
- #2816 - Generated JPA query with incorrect argument binding indexes
- #1413 - Incorrect parameter values with Hibernate custom types
- #1429 - Reusing of constants in JPQL generation causes issues with hibernate query caching
- Java 8 minimal requirement. If you still rely on Java <7, please use the latest 4.x.x version.
JavaSE6SQLExceptionWrapperand other parts regarding pre-Java 7 exception handling are removed.- Removed bridge method that were in place for backwards compatibility of legacy API's. This may lead to some breaking API changes.
- Removed Guava as a dependency. If your application relies on Guava, make sure to add it as a direct dependency for your project and not rely on QueryDSL shipping it transitively.
- 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.codegenis nowcom.querydsl.codegen.utils. This for example affectscom.mysema.codegen.model.SimpleType. Although many applications won't touch the codgen internal classes, custom APT extensions might be affected by this. - Due to the removal of Guava, any method that received an
ImmutableListas parameter, now accepts anyListinstead. Normal code should handle this signature just fine. However, make sure to check any reflective uses of these parameters. - The
querydsl.variableNameFunctionClassproperty for theDefaultConfigurationshould now be provided as ajava.util.function.Functioninstead of acom.google.common.base.Function. CodeWriter#beginStaticMethodnow takes ajava.util.function.Functioninstead of acom.google.common.base.Function.AbstractLuceneQuerynow takes ajava.util.function.Functioninstead of acom.google.common.base.Function.AbstractMongodbQuerynow takes ajava.util.function.Functioninstead of acom.google.common.base.Function.com.querydsl.codegen.NamingFunction,EvaluatorFunction,DefaultVariableFunctionnow extendjava.util.function.Functioninstead ofcom.google.common.base.Function.- Any constructor that received a
javax.inject.Provider, now takes ajava.util.function.Supplierinstead. In most cases you can replace the argument withprovider::get. - This release targets Hibernate 5.2 in the Hibernate integration. If you need Hibernate 4 dialect specific workarounds, use the
HQLTemplatesinstead of theHibernate5Templates. - Removal of various deprecated methods.
joda-time:joda-timeis now an optional dependency. If your application relies onjoda-time:joda-timemake sure to specify it as a direct dependency rather than relying on QueryDSL to include it transitively.com.google.code.findbugs:jsr305is 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 now use an underscore instead of a dot as separator:
querydsl.querynow isquerydsl_queryandquerydsl.parametersisquerydsl_parameters. - Removal of
PolyHedralSurfaceinquerydsl-spatialandquerydsl-sql-spatialdue to the upgrade ofgeolatte-geom. com.querydsl.apt.Extensionmoved tocom.querydsl.codegenand now resides in thequerydsl-codegenmodule.com.querydsl.apt.SpatialSupportmoved tocom.querydsl.spatial.apt.SpatialSupportand now resides in thequerydsl-spatialmodule.com.querydsl.sql.codegen.SpatialSupportmoved tocom.querydsl.sql.spatial.SpatialSupportand now resides in thequerydsl-sql-spatialmodule.SQLServerGeometryReaderinquerydsl-sql-spatialis removed in favour oforg.geolatte.geom.codec.db.sqlserver.*.PGgeometryConverterinquerydsl-sql-spatialis removed in favour oforg.geolatte.geom.codec.Wkt.JGeometryConverterinquerydsl-sql-spatialis removed in favour oforg.geolatte.geom.codec.db.oracle.*.- Removal of
HibernateDomainExporterinquerysql-jpa-codegen.HibernateDomainExporteronly supported Hibernate 4, which QueryDSL no longer actively supports. Instead, use theJPADomainExporterwith Hibernate. ComparableExpression#coalesce(and subtypes) no longer return a mutableCoalesceexpression, but instead return a typed expression. If you need the Coalesce builder, usenew Coalesce<T>().add(expression)instead.getConstantToNamedLabel,getConstantToNumberedLabelandgetConstantToAllLabelsthat were temporarily introduced toSerializerBaseandJPQLSerializerin QueryDSL 4.3.0 to eventually replacegetConstantToLabelare now removed in favor ofgetConstants.
AbstractJPAQuery#fetchResultsandAbstractJPAQuery#fetchCountare now deprecated for queries that have multiple group by expressions or a having clause, because these scenarios cannot be supported by pure JPA and are instead computed in-memory. If the total count of results is not necessary, we recommend to always useAbstractJPAQuery#fetchinstead. If you want a reliable way of computing the result count for a paginated result for even the most complicated queries, we recommend using the Blaze-Persistence QueryDSL integration.BlazeJPAQueryproperly implements bothfetchResultsandfetchCountand even comes with apagemethod.getConstantToLabelwhich was deprecated in QueryDSL 4.3.0 is no longer deprecated.
cglib:cglibto 3.3.0 for Java 8+ supportorg.eclipse.jdt.core.compiler:ecjto 4.6.1 for Java 8+ supportjoda-time:joda-timeto 2.10.10 for better interoperability with other frameworks that use more recent versions than QueryDSL.joda-time:joda-timeis also no longer a required dependency and as such is no longer provided transitively to your application. If your application relies onjoda-time:joda-timebeing available, make sure to add the dependency to your project.org.geolatte:geolatte-geomto 1.8.1 for better interopability with Hibernate Spatial.querydsl-spatialis still backwards compatible with older versions of Geolatte, however,querydsl-sql-spatialis not and requires 1.4.0 or newer.com.vividsolutions:jtstoorg.locationtech:jtsfor better interopability with Hibernate Spatial.com.vividsolutions:jtsis still supported forquerydsl-spatialif an older version oforg.geolatte:geolatte-geomis provided.- DataNucleus 5.2.x for Java 8+ support
- JDO now uses
org.datanucleus:javax.jdoinstead ofjavax.jdo:jdo-api
- JDO now uses
com.google.guava:guavais no longer a dependency of QueryDSL and as such is no longer provided transitively to your application. If your application relies oncom.google.guava:guavabeing available, make sure to add the dependency to your project.com.google.code.findbugs:jsr305is no longer a dependency of QueryDSL and as such is no longer provided transitively to your application. If your application relies oncom.google.code.findbugs:jsr305being available, make sure to add the dependency to your project.