Browse Source

DATAMONGO-1238 - Upgraded to Querydsl 4.

pull/334/head
Oliver Gierke 10 years ago
parent
commit
9dce117555
  1. 6
      spring-data-mongodb/pom.xml
  2. 18
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/MongoAnnotationProcessor.java
  3. 60
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/QueryDslMongoRepository.java
  4. 12
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/QuerydslRepositorySupport.java
  5. 13
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SpringDataMongodbQuery.java
  6. 43
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SpringDataMongodbSerializer.java
  7. 10
      spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapping/BasePerson.java
  8. 4
      spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/Address.java
  9. 2
      spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/support/QueryDslMongoRepositoryIntegrationTests.java
  10. 10
      spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/support/QuerydslRepositorySupportTests.java
  11. 9
      spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/support/SpringDataMongodbSerializerUnitTests.java
  12. 2
      spring-data-mongodb/template.mf

6
spring-data-mongodb/pom.xml

@ -59,14 +59,14 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.mysema.querydsl</groupId> <groupId>com.querydsl</groupId>
<artifactId>querydsl-mongodb</artifactId> <artifactId>querydsl-mongodb</artifactId>
<version>${querydsl}</version> <version>${querydsl}</version>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.mysema.querydsl</groupId> <groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId> <artifactId>querydsl-apt</artifactId>
<version>${querydsl}</version> <version>${querydsl}</version>
<scope>provided</scope> <scope>provided</scope>
@ -183,7 +183,7 @@
<version>${apt}</version> <version>${apt}</version>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.mysema.querydsl</groupId> <groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId> <artifactId>querydsl-apt</artifactId>
<version>${querydsl}</version> <version>${querydsl}</version>
</dependency> </dependency>

18
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/MongoAnnotationProcessor.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2011-2013 the original author or authors. * Copyright 2011-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,14 +25,14 @@ import javax.tools.Diagnostic;
import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Document;
import com.mysema.query.annotations.QueryEmbeddable; import com.querydsl.apt.AbstractQuerydslProcessor;
import com.mysema.query.annotations.QueryEmbedded; import com.querydsl.apt.Configuration;
import com.mysema.query.annotations.QueryEntities; import com.querydsl.apt.DefaultConfiguration;
import com.mysema.query.annotations.QuerySupertype; import com.querydsl.core.annotations.QueryEmbeddable;
import com.mysema.query.annotations.QueryTransient; import com.querydsl.core.annotations.QueryEmbedded;
import com.mysema.query.apt.AbstractQuerydslProcessor; import com.querydsl.core.annotations.QueryEntities;
import com.mysema.query.apt.Configuration; import com.querydsl.core.annotations.QuerySupertype;
import com.mysema.query.apt.DefaultConfiguration; import com.querydsl.core.annotations.QueryTransient;
/** /**
* Annotation processor to create Querydsl query types for QueryDsl annotated classes. * Annotation processor to create Querydsl query types for QueryDsl annotated classes.

60
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/QueryDslMongoRepository.java

@ -34,12 +34,12 @@ import org.springframework.data.repository.core.EntityInformation;
import org.springframework.data.repository.core.EntityMetadata; import org.springframework.data.repository.core.EntityMetadata;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import com.mysema.query.mongodb.MongodbQuery; import com.querydsl.core.types.EntityPath;
import com.mysema.query.types.EntityPath; import com.querydsl.core.types.Expression;
import com.mysema.query.types.Expression; import com.querydsl.core.types.OrderSpecifier;
import com.mysema.query.types.OrderSpecifier; import com.querydsl.core.types.Predicate;
import com.mysema.query.types.Predicate; import com.querydsl.core.types.dsl.PathBuilder;
import com.mysema.query.types.path.PathBuilder; import com.querydsl.mongodb.AbstractMongodbQuery;
/** /**
* Special QueryDsl based repository implementation that allows execution {@link Predicate}s in various forms. * Special QueryDsl based repository implementation that allows execution {@link Predicate}s in various forms.
@ -47,8 +47,8 @@ import com.mysema.query.types.path.PathBuilder;
* @author Oliver Gierke * @author Oliver Gierke
* @author Thomas Darimont * @author Thomas Darimont
*/ */
public class QueryDslMongoRepository<T, ID extends Serializable> extends SimpleMongoRepository<T, ID> implements public class QueryDslMongoRepository<T, ID extends Serializable> extends SimpleMongoRepository<T, ID>
QueryDslPredicateExecutor<T> { implements QueryDslPredicateExecutor<T> {
private final PathBuilder<T> builder; private final PathBuilder<T> builder;
private final EntityInformation<T, ID> entityInformation; private final EntityInformation<T, ID> entityInformation;
@ -92,7 +92,7 @@ public class QueryDslMongoRepository<T, ID extends Serializable> extends SimpleM
*/ */
@Override @Override
public T findOne(Predicate predicate) { public T findOne(Predicate predicate) {
return createQueryFor(predicate).uniqueResult(); return createQueryFor(predicate).fetchOne();
} }
/* /*
@ -101,7 +101,7 @@ public class QueryDslMongoRepository<T, ID extends Serializable> extends SimpleM
*/ */
@Override @Override
public List<T> findAll(Predicate predicate) { public List<T> findAll(Predicate predicate) {
return createQueryFor(predicate).list(); return createQueryFor(predicate).fetchResults().getResults();
} }
/* /*
@ -110,7 +110,7 @@ public class QueryDslMongoRepository<T, ID extends Serializable> extends SimpleM
*/ */
@Override @Override
public List<T> findAll(Predicate predicate, OrderSpecifier<?>... orders) { public List<T> findAll(Predicate predicate, OrderSpecifier<?>... orders) {
return createQueryFor(predicate).orderBy(orders).list(); return createQueryFor(predicate).orderBy(orders).fetchResults().getResults();
} }
/* /*
@ -119,7 +119,7 @@ public class QueryDslMongoRepository<T, ID extends Serializable> extends SimpleM
*/ */
@Override @Override
public List<T> findAll(Predicate predicate, Sort sort) { public List<T> findAll(Predicate predicate, Sort sort) {
return applySorting(createQueryFor(predicate), sort).list(); return applySorting(createQueryFor(predicate), sort).fetchResults().getResults();
} }
/* /*
@ -128,7 +128,7 @@ public class QueryDslMongoRepository<T, ID extends Serializable> extends SimpleM
*/ */
@Override @Override
public Iterable<T> findAll(OrderSpecifier<?>... orders) { public Iterable<T> findAll(OrderSpecifier<?>... orders) {
return createQuery().orderBy(orders).list(); return createQuery().orderBy(orders).fetchResults().getResults();
} }
/* /*
@ -138,10 +138,11 @@ public class QueryDslMongoRepository<T, ID extends Serializable> extends SimpleM
@Override @Override
public Page<T> findAll(Predicate predicate, Pageable pageable) { public Page<T> findAll(Predicate predicate, Pageable pageable) {
MongodbQuery<T> countQuery = createQueryFor(predicate); AbstractMongodbQuery<T, SpringDataMongodbQuery<T>> countQuery = createQueryFor(predicate);
MongodbQuery<T> query = createQueryFor(predicate); AbstractMongodbQuery<T, SpringDataMongodbQuery<T>> query = createQueryFor(predicate);
return new PageImpl<T>(applyPagination(query, pageable).list(), pageable, countQuery.count()); return new PageImpl<T>(applyPagination(query, pageable).fetchResults().getResults(), pageable,
countQuery.fetchCount());
} }
/* /*
@ -151,10 +152,11 @@ public class QueryDslMongoRepository<T, ID extends Serializable> extends SimpleM
@Override @Override
public Page<T> findAll(Pageable pageable) { public Page<T> findAll(Pageable pageable) {
MongodbQuery<T> countQuery = createQuery(); AbstractMongodbQuery<T, SpringDataMongodbQuery<T>> countQuery = createQuery();
MongodbQuery<T> query = createQuery(); AbstractMongodbQuery<T, SpringDataMongodbQuery<T>> query = createQuery();
return new PageImpl<T>(applyPagination(query, pageable).list(), pageable, countQuery.count()); return new PageImpl<T>(applyPagination(query, pageable).fetchResults().getResults(), pageable,
countQuery.fetchCount());
} }
/* /*
@ -163,7 +165,7 @@ public class QueryDslMongoRepository<T, ID extends Serializable> extends SimpleM
*/ */
@Override @Override
public List<T> findAll(Sort sort) { public List<T> findAll(Sort sort) {
return applySorting(createQuery(), sort).list(); return applySorting(createQuery(), sort).fetchResults().getResults();
} }
/* /*
@ -172,7 +174,7 @@ public class QueryDslMongoRepository<T, ID extends Serializable> extends SimpleM
*/ */
@Override @Override
public long count(Predicate predicate) { public long count(Predicate predicate) {
return createQueryFor(predicate).count(); return createQueryFor(predicate).fetchCount();
} }
/* /*
@ -181,7 +183,7 @@ public class QueryDslMongoRepository<T, ID extends Serializable> extends SimpleM
*/ */
@Override @Override
public boolean exists(Predicate predicate) { public boolean exists(Predicate predicate) {
return createQueryFor(predicate).exists(); return createQueryFor(predicate).fetchCount() > 0;
} }
/** /**
@ -190,7 +192,7 @@ public class QueryDslMongoRepository<T, ID extends Serializable> extends SimpleM
* @param predicate * @param predicate
* @return * @return
*/ */
private MongodbQuery<T> createQueryFor(Predicate predicate) { private AbstractMongodbQuery<T, SpringDataMongodbQuery<T>> createQueryFor(Predicate predicate) {
return createQuery().where(predicate); return createQuery().where(predicate);
} }
@ -199,7 +201,7 @@ public class QueryDslMongoRepository<T, ID extends Serializable> extends SimpleM
* *
* @return * @return
*/ */
private MongodbQuery<T> createQuery() { private AbstractMongodbQuery<T, SpringDataMongodbQuery<T>> createQuery() {
return new SpringDataMongodbQuery<T>(mongoOperations, entityInformation.getJavaType()); return new SpringDataMongodbQuery<T>(mongoOperations, entityInformation.getJavaType());
} }
@ -210,7 +212,8 @@ public class QueryDslMongoRepository<T, ID extends Serializable> extends SimpleM
* @param pageable * @param pageable
* @return * @return
*/ */
private MongodbQuery<T> applyPagination(MongodbQuery<T> query, Pageable pageable) { private AbstractMongodbQuery<T, SpringDataMongodbQuery<T>> applyPagination(
AbstractMongodbQuery<T, SpringDataMongodbQuery<T>> query, Pageable pageable) {
if (pageable == null) { if (pageable == null) {
return query; return query;
@ -227,7 +230,8 @@ public class QueryDslMongoRepository<T, ID extends Serializable> extends SimpleM
* @param sort * @param sort
* @return * @return
*/ */
private MongodbQuery<T> applySorting(MongodbQuery<T> query, Sort sort) { private AbstractMongodbQuery<T, SpringDataMongodbQuery<T>> applySorting(
AbstractMongodbQuery<T, SpringDataMongodbQuery<T>> query, Sort sort) {
if (sort == null) { if (sort == null) {
return query; return query;
@ -260,7 +264,7 @@ public class QueryDslMongoRepository<T, ID extends Serializable> extends SimpleM
Expression<Object> property = builder.get(order.getProperty()); Expression<Object> property = builder.get(order.getProperty());
return new OrderSpecifier(order.isAscending() ? com.mysema.query.types.Order.ASC return new OrderSpecifier(
: com.mysema.query.types.Order.DESC, property); order.isAscending() ? com.querydsl.core.types.Order.ASC : com.querydsl.core.types.Order.DESC, property);
} }
} }

12
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/QuerydslRepositorySupport.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2011-2012 the original author or authors. * Copyright 2011-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,8 +20,8 @@ import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity; import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import com.mysema.query.mongodb.MongodbQuery; import com.querydsl.core.types.EntityPath;
import com.mysema.query.types.EntityPath; import com.querydsl.mongodb.AbstractMongodbQuery;
/** /**
* Base class to create repository implementations based on Querydsl. * Base class to create repository implementations based on Querydsl.
@ -36,7 +36,7 @@ public abstract class QuerydslRepositorySupport {
/** /**
* Creates a new {@link QuerydslRepositorySupport} for the given {@link MongoOperations}. * Creates a new {@link QuerydslRepositorySupport} for the given {@link MongoOperations}.
* *
* @param operations must not be {@literal null} * @param operations must not be {@literal null}.
*/ */
public QuerydslRepositorySupport(MongoOperations operations) { public QuerydslRepositorySupport(MongoOperations operations) {
@ -53,7 +53,7 @@ public abstract class QuerydslRepositorySupport {
* @param path * @param path
* @return * @return
*/ */
protected <T> MongodbQuery<T> from(final EntityPath<T> path) { protected <T> AbstractMongodbQuery<T, SpringDataMongodbQuery<T>> from(final EntityPath<T> path) {
Assert.notNull(path); Assert.notNull(path);
MongoPersistentEntity<?> entity = context.getPersistentEntity(path.getType()); MongoPersistentEntity<?> entity = context.getPersistentEntity(path.getType());
return from(path, entity.getCollection()); return from(path, entity.getCollection());
@ -66,7 +66,7 @@ public abstract class QuerydslRepositorySupport {
* @param collection must not be blank or {@literal null} * @param collection must not be blank or {@literal null}
* @return * @return
*/ */
protected <T> MongodbQuery<T> from(final EntityPath<T> path, String collection) { protected <T> AbstractMongodbQuery<T, SpringDataMongodbQuery<T>> from(final EntityPath<T> path, String collection) {
Assert.notNull(path); Assert.notNull(path);
Assert.hasText(collection); Assert.hasText(collection);

13
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SpringDataMongodbQuery.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2012 the original author or authors. * Copyright 2012-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,14 +20,14 @@ import org.springframework.data.mongodb.core.MongoOperations;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.mongodb.DBCollection; import com.mongodb.DBCollection;
import com.mongodb.DBObject; import com.mongodb.DBObject;
import com.mysema.query.mongodb.MongodbQuery; import com.querydsl.mongodb.AbstractMongodbQuery;
/** /**
* Spring Data specfic {@link MongodbQuery} implementation. * Spring Data specific {@link MongodbQuery} implementation.
* *
* @author Oliver Gierke * @author Oliver Gierke
*/ */
class SpringDataMongodbQuery<T> extends MongodbQuery<T> { class SpringDataMongodbQuery<T> extends AbstractMongodbQuery<T, SpringDataMongodbQuery<T>> {
private final MongoOperations operations; private final MongoOperations operations;
@ -48,7 +48,8 @@ class SpringDataMongodbQuery<T> extends MongodbQuery<T> {
* @param type must not be {@literal null}. * @param type must not be {@literal null}.
* @param collectionName must not be {@literal null} or empty. * @param collectionName must not be {@literal null} or empty.
*/ */
public SpringDataMongodbQuery(final MongoOperations operations, final Class<? extends T> type, String collectionName) { public SpringDataMongodbQuery(final MongoOperations operations, final Class<? extends T> type,
String collectionName) {
super(operations.getCollection(collectionName), new Function<DBObject, T>() { super(operations.getCollection(collectionName), new Function<DBObject, T>() {
public T apply(DBObject input) { public T apply(DBObject input) {
@ -61,7 +62,7 @@ class SpringDataMongodbQuery<T> extends MongodbQuery<T> {
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see com.mysema.query.mongodb.MongodbQuery#getCollection(java.lang.Class) * @see com.querydsl.mongodb.AbstractMongodbQuery#getCollection(java.lang.Class)
*/ */
@Override @Override
protected DBCollection getCollection(Class<?> type) { protected DBCollection getCollection(Class<?> type) {

43
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SpringDataMongodbSerializer.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2011-2014 the original author or authors. * Copyright 2011-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -29,12 +29,10 @@ import org.springframework.util.Assert;
import com.mongodb.DBObject; import com.mongodb.DBObject;
import com.mongodb.DBRef; import com.mongodb.DBRef;
import com.mysema.query.mongodb.MongodbSerializer; import com.querydsl.core.types.Path;
import com.mysema.query.types.Constant; import com.querydsl.core.types.PathMetadata;
import com.mysema.query.types.Operation; import com.querydsl.core.types.PathType;
import com.mysema.query.types.Path; import com.querydsl.mongodb.MongodbSerializer;
import com.mysema.query.types.PathMetadata;
import com.mysema.query.types.PathType;
/** /**
* Custom {@link MongodbSerializer} to take mapping information into account when building keys for constraints. * Custom {@link MongodbSerializer} to take mapping information into account when building keys for constraints.
@ -76,10 +74,10 @@ class SpringDataMongodbSerializer extends MongodbSerializer {
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see com.mysema.query.mongodb.MongodbSerializer#getKeyForPath(com.mysema.query.types.Path, com.mysema.query.types.PathMetadata) * @see com.querydsl.mongodb.MongodbSerializer#getKeyForPath(com.querydsl.core.types.Path, com.querydsl.core.types.PathMetadata)
*/ */
@Override @Override
protected String getKeyForPath(Path<?> expr, PathMetadata<?> metadata) { protected String getKeyForPath(Path<?> expr, PathMetadata metadata) {
if (!metadata.getPathType().equals(PathType.PROPERTY)) { if (!metadata.getPathType().equals(PathType.PROPERTY)) {
return super.getKeyForPath(expr, metadata); return super.getKeyForPath(expr, metadata);
@ -94,7 +92,7 @@ class SpringDataMongodbSerializer extends MongodbSerializer {
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see com.mysema.query.mongodb.MongodbSerializer#asDBObject(java.lang.String, java.lang.Object) * @see com.querydsl.mongodb.MongodbSerializer#asDBObject(java.lang.String, java.lang.Object)
*/ */
@Override @Override
protected DBObject asDBObject(String key, Object value) { protected DBObject asDBObject(String key, Object value) {
@ -108,7 +106,7 @@ class SpringDataMongodbSerializer extends MongodbSerializer {
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see com.mysema.query.mongodb.MongodbSerializer#isReference(com.mysema.query.types.Path) * @see com.querydsl.mongodb.MongodbSerializer#isReference(com.querydsl.core.types.Path)
*/ */
@Override @Override
protected boolean isReference(Path<?> path) { protected boolean isReference(Path<?> path) {
@ -119,34 +117,13 @@ class SpringDataMongodbSerializer extends MongodbSerializer {
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see com.mysema.query.mongodb.MongodbSerializer#asReference(java.lang.Object) * @see com.querydsl.mongodb.MongodbSerializer#asReference(java.lang.Object)
*/ */
@Override @Override
protected DBRef asReference(Object constant) { protected DBRef asReference(Object constant) {
return converter.toDBRef(constant, null); return converter.toDBRef(constant, null);
} }
/*
* (non-Javadoc)
* @see com.mysema.query.mongodb.MongodbSerializer#asReference(com.mysema.query.types.Operation, int)
*/
@Override
protected DBRef asReference(Operation<?> expr, int constIndex) {
for (Object arg : expr.getArgs()) {
if (arg instanceof Path) {
MongoPersistentProperty property = getPropertyFor((Path<?>) arg);
Object constant = ((Constant<?>) expr.getArg(constIndex)).getConstant();
return converter.toDBRef(constant, property);
}
}
return super.asReference(expr, constIndex);
}
private MongoPersistentProperty getPropertyFor(Path<?> path) { private MongoPersistentProperty getPropertyFor(Path<?> path) {
Path<?> parent = path.getMetadata().getParent(); Path<?> parent = path.getMetadata().getParent();

10
spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapping/BasePerson.java

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011 by the original author(s). * Copyright 2011-2015 by the original author(s).
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,14 +16,15 @@
package org.springframework.data.mongodb.core.mapping; package org.springframework.data.mongodb.core.mapping;
import com.mysema.query.annotations.QuerySupertype; import com.querydsl.core.annotations.QuerySupertype;
/** /**
* {@link QuerySupertype} is necessary for Querydsl 2.2.0-beta4 to compile the query classes directly. Can be removed as * {@link QuerySupertype} is necessary for Querydsl 2.2.0-beta4 to compile the query classes directly. Can be removed as
* soon as {@link https://bugs.launchpad.net/querydsl/+bug/776219} is fixed. * soon as {@link https://bugs.launchpad.net/querydsl/+bug/776219} is fixed.
* *
* @see https://bugs.launchpad.net/querydsl/+bug/776219 * @see https://bugs.launchpad.net/querydsl/+bug/776219
* @author Jon Brisbin <jbrisbin@vmware.com> * @author Jon Brisbin
* @author Oliver Gierke
*/ */
@QuerySupertype @QuerySupertype
public abstract class BasePerson { public abstract class BasePerson {
@ -32,8 +33,7 @@ public abstract class BasePerson {
protected String firstName; protected String firstName;
protected String lastName; protected String lastName;
public BasePerson() { public BasePerson() {}
}
public BasePerson(Integer ssn, String firstName, String lastName) { public BasePerson(Integer ssn, String firstName, String lastName) {
this.ssn = ssn; this.ssn = ssn;

4
spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/Address.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2011 the original author or authors. * Copyright 2011-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +15,7 @@
*/ */
package org.springframework.data.mongodb.repository; package org.springframework.data.mongodb.repository;
import com.mysema.query.annotations.QueryEmbeddable; import com.querydsl.core.annotations.QueryEmbeddable;
/** /**
* @author Oliver Gierke * @author Oliver Gierke

2
spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/support/QueryDslMongoRepositoryIntegrationTests.java

@ -34,7 +34,7 @@ import org.springframework.data.mongodb.repository.query.MongoEntityInformation;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.mysema.query.types.Predicate; import com.querydsl.core.types.Predicate;
/** /**
* Integration test for {@link QueryDslMongoRepository}. * Integration test for {@link QueryDslMongoRepository}.

10
spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/support/QuerydslRepositorySupportTests.java

@ -31,8 +31,6 @@ import org.springframework.data.mongodb.repository.QPerson;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.mysema.query.mongodb.MongodbQuery;
/** /**
* Unit tests for {@link QuerydslRepositorySupport}. * Unit tests for {@link QuerydslRepositorySupport}.
* *
@ -59,8 +57,8 @@ public class QuerydslRepositorySupportTests {
QPerson p = QPerson.person; QPerson p = QPerson.person;
QuerydslRepositorySupport support = new QuerydslRepositorySupport(operations) {}; QuerydslRepositorySupport support = new QuerydslRepositorySupport(operations) {};
MongodbQuery<Person> query = support.from(p).where(p.lastname.eq("Matthews")); SpringDataMongodbQuery<Person> query = support.from(p).where(p.lastname.eq("Matthews"));
assertThat(query.uniqueResult(), is(person)); assertThat(query.fetchOne(), is(person));
} }
/** /**
@ -76,8 +74,8 @@ public class QuerydslRepositorySupportTests {
QPerson p = QPerson.person; QPerson p = QPerson.person;
QuerydslRepositorySupport support = new QuerydslRepositorySupport(operations) {}; QuerydslRepositorySupport support = new QuerydslRepositorySupport(operations) {};
MongodbQuery<Person> query = support.from(p).where(p.skills.any().in("guitarist")); SpringDataMongodbQuery<Person> query = support.from(p).where(p.skills.any().in("guitarist"));
assertThat(query.uniqueResult(), is(person)); assertThat(query.fetchOne(), is(person));
} }
} }

9
spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/support/SpringDataMongodbSerializerUnitTests.java

@ -37,10 +37,10 @@ import org.springframework.data.mongodb.repository.QPerson;
import com.mongodb.BasicDBList; import com.mongodb.BasicDBList;
import com.mongodb.BasicDBObject; import com.mongodb.BasicDBObject;
import com.mongodb.DBObject; import com.mongodb.DBObject;
import com.mysema.query.types.expr.BooleanOperation; import com.querydsl.core.types.dsl.BooleanOperation;
import com.mysema.query.types.path.PathBuilder; import com.querydsl.core.types.dsl.PathBuilder;
import com.mysema.query.types.path.SimplePath; import com.querydsl.core.types.dsl.SimplePath;
import com.mysema.query.types.path.StringPath; import com.querydsl.core.types.dsl.StringPath;
/** /**
* Unit tests for {@link SpringDataMongodbSerializer}. * Unit tests for {@link SpringDataMongodbSerializer}.
@ -73,6 +73,7 @@ public class SpringDataMongodbSerializerUnitTests {
@Test @Test
public void buildsNestedKeyCorrectly() { public void buildsNestedKeyCorrectly() {
StringPath path = QPerson.person.address.street; StringPath path = QPerson.person.address.street;
assertThat(serializer.getKeyForPath(path, path.getMetadata()), is("street")); assertThat(serializer.getKeyForPath(path, path.getMetadata()), is("street"));
} }

2
spring-data-mongodb/template.mf

@ -10,7 +10,7 @@ Import-Template:
com.fasterxml.jackson.*;version="${jackson:[=.=.=,+1.0.0)}";resolution:=optional, com.fasterxml.jackson.*;version="${jackson:[=.=.=,+1.0.0)}";resolution:=optional,
com.google.common.base.*;version="[11.0.0,14.0.0)";resolution:=optional, com.google.common.base.*;version="[11.0.0,14.0.0)";resolution:=optional,
com.mongodb.*;version="${mongo.osgi:[=.=.=,+1.0.0)}", com.mongodb.*;version="${mongo.osgi:[=.=.=,+1.0.0)}",
com.mysema.query.*;version="[2.1.1, 3.0.0)";resolution:=optional, com.querydsl.*;version="${querydsl:[=.=.=,+1.0.0)}";resolution:=optional,
javax.annotation.processing.*;version="0", javax.annotation.processing.*;version="0",
javax.enterprise.*;version="${cdi:[=.=.=,+1.0.0)}";resolution:=optional, javax.enterprise.*;version="${cdi:[=.=.=,+1.0.0)}";resolution:=optional,
javax.tools.*;version="0", javax.tools.*;version="0",

Loading…
Cancel
Save