querydsl/querydsl-collections
Zoltán Reegn 3a74aaeabc Explicitly declare NonUniqueResultException for fetchOne
Fetchable.fetchOne() declares in it's javadoc that it throws
NonUniqueResultException. It should therefore be explicitly declared in
the method signature as well.
All implementations must also declare in their signature that they throw.

This also has the desirable side-effect of the javadoc of all of the
implementors inheriting the @throws section from the javadoc of the
interface as well.

Fixes #2232
2018-01-16 14:03:05 +01:00
..
src Explicitly declare NonUniqueResultException for fetchOne 2018-01-16 14:03:05 +01:00
pom.xml Bump version 2016-09-05 22:35:47 +03:00
README.md Update examples in readme to Querydsl 4 syntax 2016-05-30 20:54:23 +02:00

Querydsl Collections

The Collections module provides integration with Java Collections and Beans.

Maven integration

Add the following dependencies to your Maven project :

<dependency>
  <groupId>com.querydsl</groupId>
  <artifactId>querydsl-apt</artifactId>
  <version>${querydsl.version}</version>
  <scope>provided</scope>
</dependency>
<dependency>
  <groupId>com.querydsl</groupId>
  <artifactId>querydsl-collections</artifactId>
  <version>${querydsl.version}</version>
</dependency>
<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-log4j12</artifactId>
  <version>1.6.1</version>
</dependency>   

If you are not using JPA or JDO you can generate Querydsl query types for your domain types by annotating them with the com.querydsl.core.annotations.QueryEntity annotation and adding the following plugin configuration into your Maven configuration (pom.xml) :

<project>
  <build>
    <plugins>
      ...
      <plugin>
        <groupId>com.mysema.maven</groupId>
        <artifactId>apt-maven-plugin</artifactId>
        <version>1.1.3</version>
        <executions>
          <execution>
            <goals>
              <goal>process</goal>
            </goals>
            <configuration>
              <outputDirectory>target/generated-sources/java</outputDirectory>
              <processor>com.querydsl.apt.QuerydslAnnotationProcessor</processor>
            </configuration>
          </execution>
        </executions>
      </plugin>
      ...
    </plugins>
  </build>
</project>

Querying

Querying with Querydsl Collections is as simple as this :

import static com.querydsl.collections.CollQueryFactory.*;

QCat cat = new QCat("cat");
for (String name : from(cat,cats)
  .select(cat.name)
  .where(cat.kittens.size().gt(0))
  .fetch()){
    System.out.println(name);
}

For more information on the Querydsl Collections module visit the reference documentation http://www.querydsl.com/static/querydsl/latest/reference/html/ch02s08.html