При выполнении запроса dsl я получаю ошибку ниже.
018-05-01 13:18:38.517 DEBUG 372 --- [nio-8080-exec-1] o.s.b.c.web.OrderedRequestContextFilter : Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@308cc4e8
2018-05-01 13:18:38.520 ERROR 372 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[.[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [/boot] threw exception [Handler processing failed; nested exception is java.lang.NoSuchFieldError: LIKE_IC] with root cause
java.lang.NoSuchFieldError: LIKE_IC
at com.mysema.query.jpa.JPQLTemplates.<clinit>(JPQLTemplates.java:38) ~[querydsl-jpa-3.7.4.jar:na]
Когда я снова нажимаю на тот же запрос, я получаю другое исключение:
2018-05-01 13:36:47.839 DEBUG 7964 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet : Could not complete request
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.mysema.query.jpa.HQLTemplates
at org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1305) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:979) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:895) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967) [spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:869) [spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648) [tomcat-embed-core-8.0.33.jar:8.0.33]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843) [spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) [tomcat-embed-core-8.0.33.jar:8.0.33]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) [tomcat-embed-core-8.0.33.jar:8.0.33]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [tomcat-embed-core-8.0.33.jar:8.0.33]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-embed-websocket-8.0.33.jar:8.0.33]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [tomcat-embed-core-8.0.33.jar:8.0.33]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [tomcat-embed-core-8.0.33.jar:8.0.33]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.web.filter.OncePerRequ
Мой класс домена, как показано ниже, по которому я вызываю поисковый запрос dsl
package com.springboot.model;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@Entity
@Table(name = "app_user", catalog = "testdb")
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
public class AppUser implements java.io.Serializable {
Integer id;
private Rank rank;
private Trainingstatus trainingstatus;
private String name;
private int age;
private double salary;
Set<Address> addresses = new HashSet<Address>(0);
public AppUser(Rank rank, Trainingstatus trainingstatus, String name, int age, double salary,
Set<Address> addresses) {
this.rank = rank;
this.trainingstatus = trainingstatus;
this.name = name;
this.age = age;
this.salary = salary;
this.addresses = addresses;
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "rankId", nullable = false)
//@JsonManagedReference(value="rank")
public Rank getRank() {
return this.rank;
}
public void setRank(Rank rank) {
this.rank = rank;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "trainingStatusId", nullable = false)
//@JsonManagedReference(value="trainingstatus")
/*@JsonBackReference
@JsonIgnore*/
public Trainingstatus getTrainingstatus() {
return this.trainingstatus;
}
public void setTrainingstatus(Trainingstatus trainingstatus) {
this.trainingstatus = trainingstatus;
}
@Column(name = "name", nullable = false, length = 30)
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
@Column(name = "age", nullable = false)
public int getAge() {
return this.age;
}
public void setAge(int age) {
this.age = age;
}
@Column(name = "salary", nullable = false, precision = 22, scale = 0)
public double getSalary() {
return this.salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
@OneToMany(fetch = FetchType.EAGER, mappedBy = "appUser" , cascade = CascadeType.ALL )
public Set<Address> getAddresses() {
return this.addresses;
}
public void setAddresses(Set<Address> addresses) {
this.addresses = addresses;
}
}
мой запрос DSL
QAppUser qappUser = QAppUser.appUser;
BooleanExpression rankExp = qappUser.rank.rank.equalsIgnoreCase(user.getRank().getRank());
BooleanExpression nameExp = qappUser.name.equalsIgnoreCase(user.getName());
List<AppUser> createdUser = (List<AppUser>) userRepo.findAll(nameExp.and(rankExp));77
Проект Github- https://github.com/harshalpatil2012/Springboot
Нормальные JPA-запросы здесь работают, а не query-dsl, некоторые могут помочь мне здесь.