Announcement Announcement Module
Collapse
No announcement yet.
Spring Data Examples not working? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Data Examples not working?

    I downloaded the Spring Data Examples from

    https://github.com/SpringSource/spri...a-jpa-examples

    and at least one of them seems to be broken. It references a non-existent class org.springframework.data.jpa.showcase.core.QAccoun t in the file AccountPredicates.java.

    I'd really like to get this working so I can see all the cool Spring Data stuff working - has anybody gotten these examples working? If so, how?

  • #2
    The "Q" classes (i.e., QAccount, QCustomer) are those which QueryDSL needs to do its work.

    You have to run the Maven goals "clean generate-sources" on the project in order to create them. If you look in the pom.xml file, you'll see

    Code:
    <plugin>
    	<groupId>com.mysema.maven</groupId>
    	<artifactId>maven-apt-plugin</artifactId>
    	<version>1.0.4</version>
    	<dependencies>
    		<dependency>
    			<groupId>com.mysema.querydsl</groupId>
    			<artifactId>querydsl-apt</artifactId>
    			<version>${querydsl.version}</version>
    		</dependency>
    	</dependencies>
    	<executions>
    		<execution>
    			<phase>generate-sources</phase>
    			<goals>
    				<goal>process</goal>
    			</goals>
    			<configuration>
    				<outputDirectory>target/generated-sources/queries</outputDirectory>
    				<processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
    			</configuration>
    		</execution>
    	</executions>
    </plugin>

    Create a "Runtime Configuration" under the "Maven Build" node, assuming you are using STS, or have the Maven Eclipse plugin installed. Here's a screen shot of my configuration:

    Attachment

    Once you have configured this, select the project node in Package Explorer and run the configuration.


    An alternative to doing this inside STS/Eclipse would be to do this from a command line, assuming you have mvn installed:
    mvn clean generate-sources

    Once you do that, you will see the generated files in the target/generated-sources/queries.
    Attached Files
    Last edited by pfurbacher; Jul 17th, 2013, 07:54 AM.

    Comment


    • #3
      Thank you! I have not worked with generated source files in Java before; I guess I have some reading to do. Thanks again.

      Comment


      • #4
        The subject of "generated source files in Java" could be a rather wide-ranging and nebulous one.

        I think you would save time by just reading the QueryDSL docs related to the issue.

        Getting started with Querydsl

        Querying JPA


        A quick search for "generate" across all files in the JPA examples you referred to in the original message did not find any statement regarding how to generate the required supporting files. If you have the time, it might good idea to file a JIRA issue to the effect that some mention of running the generate-sources goal is necessary in the readme file.

        Comment

        Working...
        X