Permalink
Browse files

Update examples in readme to Querydsl 4 syntax

  • Loading branch information...
1 parent e6a463f commit f5a9a8ce0b94204b0f7c4d4633aabee7531cdb27 @Shredder121 Shredder121 committed May 30, 2016
@@ -63,8 +63,9 @@ 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))
- .list(cat.name)){
+ .fetch()){
System.out.println(name);
}
```
@@ -70,10 +70,11 @@ Querying with Querydsl JDO is as simple as this :
```JAVA
QCustomer customer = QCustomer.customer;
-JDOQuery query = new JDOQuery(pm);
-Customer bob = query.from(customer)
+JDOQuery<?> query = new JDOQuery<Void>(pm);
+Customer bob = query.select(customer)
+ .from(customer)
.where(customer.firstName.eq("Bob"))
- .uniqueResult(customer);
+ .fetchOne();
query.close();
```
@@ -72,10 +72,11 @@ Querying with Querydsl JPA is as simple as this :
```JAVA
QCustomer customer = QCustomer.customer;
-JPAQuery query = new JPAQuery(entityManager);
-Customer bob = query.from(customer)
+JPAQuery<?> query = new JPAQuery<Void>(entityManager);
+Customer bob = query.select(customer)
+ .from(customer)
.where(customer.firstName.eq("Bob"))
- .uniqueResult(customer);
+ .fetchOne();
```
For more information on the Querydsl JPA module visit the reference documentation http://www.querydsl.com/static/querydsl/latest/reference/html/ch02.html#jpa_integration
@@ -53,7 +53,7 @@ IndexSearcher searcher = new IndexSearcher(index);
LuceneQuery query = new LuceneQuery(true, searcher);
List<Document> documents = query
.where(doc.year.between("1800", "2000").and(doc.title.startsWith("Huckle"))
- .list();
+ .fetch();
```
which is transformed into the following Lucene query :
@@ -52,7 +52,7 @@ IndexSearcher searcher = new IndexSearcher(index);
LuceneQuery query = new LuceneQuery(true, searcher);
List<Document> documents = query
.where(doc.year.between("1800", "2000").and(doc.title.startsWith("Huckle"))
- .list();
+ .fetch();
```
which is transformed into the following Lucene query :
@@ -52,7 +52,7 @@ IndexSearcher searcher = new IndexSearcher(index);
LuceneQuery query = new LuceneQuery(true, searcher);
List<Document> documents = query
.where(doc.year.between("1800", "2000").and(doc.title.startsWith("Huckle"))
- .list();
+ .fetch();
```
which is transformed into the following Lucene query :
@@ -69,7 +69,7 @@ QUser user = new QUser("user");
MorphiaQuery<User> query = new MorphiaQuery<User>(morphia, datastore, user);
List<User> list = query
.where(user.firstName.eq("Bob"))
- .list();
+ .fetch();
```
@@ -69,9 +69,10 @@ Querying with Querydsl SQL is as simple as this :
QCustomer customer = new QCustomer("c");
SQLTemplates dialect = new HSQLDBTemplates(); // SQL-dialect
-SQLQuery query = new SQLQuery(connection, dialect);
-List<String> lastNames = query.from(customer)
+SQLQuery<?> query = new SQLQuery<Void>(connection, dialect);
+List<String> lastNames = query.select(customer.lastName)
+ .from(customer)
.where(customer.firstName.eq("Bob"))
- .list(customer.lastName);
+ .fetch();
```
For more information on the Querydsl SQL module visit the reference documentation http://www.querydsl.com/static/querydsl/latest/reference/html/ch02s03.html

0 comments on commit f5a9a8c

Please sign in to comment.