Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何从QueryDSL检索列表/结果_Java_Spring Data_Spring Data Jpa_Querydsl - Fatal编程技术网

Java 如何从QueryDSL检索列表/结果

Java 如何从QueryDSL检索列表/结果,java,spring-data,spring-data-jpa,querydsl,Java,Spring Data,Spring Data Jpa,Querydsl,我正在使用4.0.4版本的查询DSL,这里是我的依赖项 <dependency> <groupId>com.querydsl</groupId> <artifactId>querydsl-apt</artifactId> <version>4.0.4</version> <scope>provided</scope> </dependency> <dep

我正在使用4.0.4版本的查询DSL,这里是我的依赖项

<dependency>
  <groupId>com.querydsl</groupId>
  <artifactId>querydsl-apt</artifactId>
  <version>4.0.4</version>
  <scope>provided</scope>
</dependency>

<dependency>
  <groupId>com.querydsl</groupId>
  <artifactId>querydsl-jpa</artifactId>
  <version>4.0.4</version>
</dependency>

<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-log4j12</artifactId>
  <version>1.6.1</version>
</dependency>
但是,查询方法没有list()方法 当我行
.where(quote.ticketNumber.like(“this”))

这是完整的代码

import com.querydsl.jpa.JPQLQuery;
import com.querydsl.jpa.impl.JPAQuery;
import org.app.now.domain.process.QQuotation;
import org.app.now.domain.process.Quotation;
import org.app.now.repo.QuotationRepoCustom;
import org.joda.time.LocalDateTime;
import org.springframework.beans.factory.annotation.Autowired;

import javax.persistence.EntityManager;
import java.util.List;

public class QuotationRepoImpl implements QuotationRepoCustom {

    @Autowired
    private EntityManager em;

    @Override
    public List<Quotation> search(String ticketNumber, String description, LocalDateTime startDate, LocalDateTime endDate) {
        System.out.println("Searching");
        JPQLQuery query = new JPAQuery(em);
        QQuotation quotation = QQuotation.quotation;
        query.from(quotation).where(quotation.ticketNumber.like("this")).
        return null;
    }
}
import com.querydsl.jpa.JPQLQuery;
导入com.querydsl.jpa.impl.JPAQuery;
导入org.app.now.domain.process.qquote;
导入org.app.now.domain.process.quote;
导入org.app.now.repo.QuotationRepoCustom;
导入org.joda.time.LocalDateTime;
导入org.springframework.beans.factory.annotation.Autowired;
导入javax.persistence.EntityManager;
导入java.util.List;
公共类QuotationRepoImpl实现QuotationRepoCustom{
@自动连线
私人实体管理者;
@凌驾
公共列表搜索(字符串ticketNumber、字符串描述、LocalDateTime开始日期、LocalDateTime结束日期){
System.out.println(“搜索”);
JPQLQuery query=新的JPAQuery(em);
QQUOTE QUOTE=QQUOTE.QUOTE;
query.from(quote.where(quote.ticketNumber.like(“this”))。
返回null;
}
}
看看界面

@Override
public List<Quotation> search(String ticketNumber, String description, LocalDateTime startDate, LocalDateTime endDate) {
    System.out.println("Searching");
    JPQLQuery query = new JPAQuery(em);
    QQuotation quotation = QQuotation.quotation;
    return query.from(quotation).where(quotation.ticketNumber.like("this")).fetch();
}
@覆盖
公共列表搜索(字符串ticketNumber、字符串描述、LocalDateTime开始日期、LocalDateTime结束日期){
System.out.println(“搜索”);
JPQLQuery query=新的JPAQuery(em);
QQUOTE QUOTE=QQUOTE.QUOTE;
返回query.from(quote).where(quote.ticketNumber.like(“this”)).fetch();
}
祝你好运

像这样

@Override
public List<Quotation> search(String ticketNumber, String description, LocalDateTime startDate, LocalDateTime endDate) {
    JPQLQuery<Void> query = new JPAQuery<Void>(em);
    QQuotation quotation = QQuotation.quotation;
    return query.select(quotation)
                .from(quotation)
                .where(quotation.ticketNumber.like("this"))
                .fetch();
}
@覆盖
公共列表搜索(字符串ticketNumber、字符串描述、LocalDateTime开始日期、LocalDateTime结束日期){
JPQLQuery query=新的JPAQuery(em);
QQUOTE QUOTE=QQUOTE.QUOTE;
返回查询。选择(报价单)
.来自(报价)
.where(quote.ticketNumber.like(“本”))
.fetch();
}
@Override
public List<Quotation> search(String ticketNumber, String description, LocalDateTime startDate, LocalDateTime endDate) {
    JPQLQuery<Void> query = new JPAQuery<Void>(em);
    QQuotation quotation = QQuotation.quotation;
    return query.select(quotation)
                .from(quotation)
                .where(quotation.ticketNumber.like("this"))
                .fetch();
}