Reputation: 163
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]
Upvotes: 7
Views: 3054
Reputation: 2354
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"
}
Upvotes: 5
Reputation: 1
If you are in POM base project use these dependencies and apt plugin to resolve this issue with given versions
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>4.1.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
<version></version>
</dependency>
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/java</outputDirectory>
<processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
</plugin>
Upvotes: 0