spring-projects / spring-data-rest

Simplifies building hypermedia-driven REST web services on top of Spring Data repositories
https://spring.io/projects/spring-data-rest
Apache License 2.0
914 stars 560 forks source link

queryDsl support [DATAREST-671] #1046

Open spring-projects-issues opened 9 years ago

spring-projects-issues commented 9 years ago

Florian GOURMELEN opened DATAREST-671 and commented

I'm trying to embed QueryDsl along with Spring Data & Spring Data REST but when I annotate my repository with QueryDslPredicateExecutor then I get the following error on startup:

org.springframework.data.mapping.PropertyReferenceException: No property findAll found for type Role!

example

public interface RoleRepository extends PagingAndSortingRepository<Role, Long>,
    QueryDslPredicateExecutor<Role> {

1 votes, 4 watchers

spring-projects-issues commented 9 years ago

Oliver Drotbohm commented

Would you mind adding the complete stack trace and which store the repository is actually backed with?

spring-projects-issues commented 9 years ago

Florian GOURMELEN commented

sure here it is: stack file

I use spring data jpa(hibernate), here is a snippet of code

@RepositoryRestResource
public interface SiteMinierRepository extends PagingAndSortingRepository<SiteMinier, String>,
    QueryDslPredicateExecutor<SiteMinier> {
}
spring-projects-issues commented 8 years ago

Kay Schecker commented

I've the same problem :/ Is there any workaround?

spring-projects-issues commented 8 years ago

Oliver Drotbohm commented

I still can't reproduce the problem because we got neither a stack trace nor a project reproducing the error nor is obvious which version might be causing the issue. The provided link is dead unfortunately. So we're basically stuck with "it doesn't work", which is quite impossible to work on.

The Starbucks sample project in the Spring Data Examples repository is using that combination and works flawlessly

spring-projects-issues commented 8 years ago

Kay Schecker commented

Ah ok, i'll paste a stack trace within the next few days. Greets to Dresden, my lovely hometown ;-)

spring-projects-issues commented 8 years ago

Kay Schecker commented

Ok i configured my project again to use querydsl. Now im unable to reproduce this issue. I attached my working pom.xml i hope this helps other developers to solve the issue too, if happen ;)

\<?xml version="1.0" encoding="UTF-8"?>

\<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>***</groupId>
<artifactId>***</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>***</name>
<description>***</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.0.RELEASE</version>
</parent>

<properties>
    <org.mapstruct.version>1.0.0.CR2</org.mapstruct.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
    <apt.version>1.1.3</apt.version>
    <querydsl.version>3.7.0</querydsl.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-hateoas</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.jayway.jsonpath</groupId>
        <artifactId>json-path-assert</artifactId>
        <version>2.1.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.jayway.jsonpath</groupId>
        <artifactId>json-path</artifactId>
        <version>2.1.0</version>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.mapstruct</groupId>
        <artifactId>mapstruct</artifactId>
        <version>${org.mapstruct.version}</version>
    </dependency>
    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>2.3</version>
    </dependency>
    <dependency>
        <groupId>com.ninja-squad</groupId>
        <artifactId>DbSetup</artifactId>
        <version>1.6.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-test</artifactId>
        <version>4.0.0.RELEASE</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>18.0</version>
    </dependency>
    <dependency>
        <groupId>com.mysema.querydsl</groupId>
        <artifactId>querydsl-jpa</artifactId>
        <version>${querydsl.version}</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>com.mysema.maven</groupId>
            <artifactId>apt-maven-plugin</artifactId>
            <version>${apt.version}</version>
            <dependencies>
                <dependency>
                    <groupId>com.mysema.querydsl</groupId>
                    <artifactId>querydsl-apt</artifactId>
                    <version>${querydsl.version}</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>target/generated-sources/java</outputDirectory>
                        <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.bsc.maven</groupId>
            <artifactId>maven-processor-plugin</artifactId>
            <version>2.2.4</version>
            <configuration>
                <defaultOutputDirectory>
                    ${project.build.directory}/generated-sources
                </defaultOutputDirectory>
                <processors>
                    <processor>org.mapstruct.ap.MappingProcessor</processor>
                </processors>
            </configuration>
            <executions>
                <execution>
                    <id>process</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>process</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>org.mapstruct</groupId>
                    <artifactId>mapstruct-processor</artifactId>
                    <version>${org.mapstruct.version}</version>
                </dependency>
            </dependencies>
        </plugin>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

\

spring-projects-issues commented 8 years ago

Florian GOURMELEN commented

sorry I couldn't reply earlier the update of dependencies worked for me as well