code is as below
QContinent continent = QContinent.continent;
JPAQuery query = new JPAQuery(entityManager);
query.from(continent).where(continent.name.eq("www"));
List<Object> fetch = query.fetch();
System.err.println("===" + fetch);
This returns
Caused by: java.lang.UnsupportedOperationException: null
at java.util.Collections$UnmodifiableMap.put(Collections.java:1457) ~[na:1.8.0_191]
at com.querydsl.jpa.JPQLSerializer.visitConstant(JPQLSerializer.java:327) ~[querydsl-jpa-4.2.1.jar:na]
at com.querydsl.core.support.SerializerBase.visit(SerializerBase.java:221) ~[querydsl-core-4.3.1.jar:na]
at com.querydsl.core.support.SerializerBase.visit(SerializerBase.java:36) ~[querydsl-core-4.3.1.jar:na]
at com.querydsl.core.types.ConstantImpl.accept(ConstantImpl.java:140) ~[querydsl-core-4.3.1.jar:na]
As suggest by @user3388770, the reason is a mismatch of versions. In general,in your pom.xml
/build.gradle
do not specify a version for dependencies, that Spring already brings with except if you really need it for some reason.
You can find the used/compatible depencies here: https://docs.spring.io/spring-boot/docs/2.3.1.RELEASE/reference/html/appendix-dependency-versions.html (change the version according to your Spring version)
In case of your error, your dependencies should look like this (build.gradle
):
plugins {
id "org.springframework.boot" version "2.3.1.RELEASE"
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
...
}
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
...
dependencies {
annotationProcessor(
...
//some put a version below before ":jpa"; dont.
"com.querydsl:querydsl-apt::jpa"
...
)
//just an example without version numbers as they are delivered with spring boot automatically
compile "org.springframework.boot:spring-boot-starter-web"
compile "org.springframework.boot:spring-boot-actuator"
...
compile group: 'org.apache.httpcomponents', name: 'httpclient'
compile 'org.thymeleaf.extras:thymeleaf-extras-java8time'
//but most importantly this below
compile "com.querydsl:querydsl-jpa"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With