querydsl

How to do a paged QueryDSL query with Spring JPA?

强颜欢笑 提交于 2019-12-08 19:34:02
问题 QueryDSL defines an OrderSpecifier interface and an instance for that can be easily obtained for any field by calling asc() or desc() . The QueryDslPredicateExecutor interface of Spring Data JPA even has a findAll() method which takes OrderSpecifier s as parameters. org.springframework.data.domain.PageRequest however doesn't know anything about QueryDSL and it has its own way for defining query sort order, namely org.springframework.data.domain.Sort . It can contain a number of org

Multiple Joins with QueryDSL

心已入冬 提交于 2019-12-08 09:21:41
问题 I'm trying to use QueryDSL with Spring Data JPA. My database has 3 tables. 1) An account table with account info and specifically an account number. 2) A PersonRole table which has a person's role on an account (like owner) and the corresponding account number and his person ID number. 3) A person table which has rows of persons. Their ID number and first name, last name etc... My entities look like this: @Entity Account{ //...Other fields ommited // ** @OneToMany @JoinColumn(name = "ACCNT

Spring Data Rest Override Repositories (Controllers vs AOP)

。_饼干妹妹 提交于 2019-12-08 07:53:06
问题 Domain/Repository Project { User owner; } //Querydsl repositories @RepositoryRestResource public interface ProjectRepository extends PagingAndSortingRepository<Project, Long>, QueryDslPredicateExecutor<Project>, QuerydslBinderCustomizer<QProject> { default void customize(QuerydslBindings bindings, QProject project) { (...) } } Requeriment: filter data according to the authenticated user context: If user is ROLE_PUBLIC show projects according predicate and where user is the owner . If user is

Spring Boot/Gradle/Querydsl project has the same dependency dependent on different versions of another dependency

让人想犯罪 __ 提交于 2019-12-08 05:27:11
问题 I am having problems adding Querydsl to my Spring Boot project. I have the following dependencies in my build.gradle file: dependencies { annotationProcessor 'com.querydsl:querydsl-apt:4.1.3:jpa' annotationProcessor 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'com.querydsl:querydsl-jpa:4.1.3' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework

How can I count the number of result groups in QueryDSL?

故事扮演 提交于 2019-12-07 20:58:48
问题 How can I implement a count-of-groups in QueryDSL (in Java)? Background I'm implementing a paged search on a table, where I want to group the results before returning them. In addition to the usual LIMIT x OFFSET y query, I also want to receive the total row count. This is the (simplified) SQL query for one page: SELECT x, y, MAX(z) FROM tasks WHERE y > 10 GROUP BY x, y LIMIT 10 OFFSET 0 To retrieve the number of rows, I tried to use a naive COUNT(*) instead of the x, y, MAX(z) like this:

QueryDSL & PostgreSQL enums?

感情迁移 提交于 2019-12-07 19:57:49
问题 We're using QueryDSL with PostgreSQL database and building our domain database first. Our Java domain beans are automatically generated using the QueryDSL Maven Plugin Version 3.6.1. First of all, is it possible to configure the QueryDSL plugin to automatically generate Java enums from the PostgreSQL database enumtypes? For example: When we have an enum: CREATE TYPE customertype AS ENUM ('person','company'); Which is used as a column type: CREATE TABLE customer (customertype customertype,...

Query DSL Q type classes not generated

佐手、 提交于 2019-12-07 12:08:24
问题 I am trying to use QueryDSL in my eclipse maven project. These are the dependencies. <properties> <!-- The main class to start by executing java -jar --> <start-class>my.app.market.DBApp</start-class> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <querydsl.version>4.1.4</querydsl.version> <apt-maven-plugin.version>1.1.3</apt-maven-plugin.version> </properties> <dependency

Create an alias on a function in querydsl

六眼飞鱼酱① 提交于 2019-12-07 08:38:44
问题 How can I create an alias of a function in querydsl , so I can use it in an ORDER BY or GROUP BY statement, or in a subquery? I tried this code : StringPath idNiv0s = Expressions.stringPath("idNiv0s"); StringExpression func = Expressions.stringTemplate("replace({0},',','')", Expressions.stringTemplate("substring_index( {0}, ',' , -2 )", ach.ancestors) ); new JPAQuery(entityManager).from(ach) .groupBy(idNiv0s) .orderBy(idNiv0s.desc()) .list(new QCritereItem( func.as(idNiv0s) , idNiv0s.count()

Configure QueryDSL on Play 2 Framework

橙三吉。 提交于 2019-12-07 08:12:27
问题 I try to configure QueryDSL in Play Framework (with Java) but without success. I've searched for similar problems in Google and this is what I found: 1. QueryDSL and Play. But this post establishing the equivalence with Lombok and the solution does not work for me. 2. Emulating MAVEN process. This is what I really need to apply it to other similar modules, but does not show an example of how. 3. Configure multiple modules. In this case includes several modules and is a bit confusing. So, how

Maven build problems with spring-data-jpa and querydsl

眉间皱痕 提交于 2019-12-07 05:51:54
问题 I've got an Eclipse Maven project for spring-data-jpa and QueryDsl. I seem to have a problem with the maven-apt-plugin where if I do a mvn clean followed by a mvn install, it tries to "process" files that reference the QueryDsl generated files, but these generated files have not yet been built so I get multiple "cannot find symbol" errors. If then have to do another mvn install, everything is ok as the generated files now exist. Does this maven-apt-plugin need to process every file in my