From c013c71e7a15a63019feba5c5bf49ca63842e482 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Fri, 22 May 2015 17:27:00 +0200 Subject: [PATCH] DATACMNS-670 - Upgraded to Querydsl 4. Switched to new Querydsl 4 artifacts and adapted to changed package names and API changes. Cleaned up some JavaDoc and APIs in QuerydslBindingsFactory and QuerydslBinderCustomizer. --- pom.xml | 10 +++++--- .../data/querydsl/EntityPathResolver.java | 6 ++--- .../data/querydsl/QPageRequest.java | 4 +-- .../springframework/data/querydsl/QSort.java | 14 ++++++----- .../querydsl/QueryDslPredicateExecutor.java | 4 +-- .../data/querydsl/QueryDslUtils.java | 6 ++--- .../QuerydslRepositoryInvokerAdapter.java | 2 +- .../querydsl/SimpleEntityPathResolver.java | 6 ++--- .../querydsl/binding/MultiValueBinding.java | 13 +++++----- .../binding/QuerydslBinderCustomizer.java | 9 ++++++- .../querydsl/binding/QuerydslBindings.java | 10 ++++---- .../binding/QuerydslBindingsFactory.java | 21 ++++++++++++++-- .../binding/QuerydslDefaultBinding.java | 10 ++++---- .../binding/QuerydslPredicateBuilder.java | 6 ++--- .../querydsl/binding/SingleValueBinding.java | 11 ++++---- .../web/config/QuerydslWebConfiguration.java | 2 +- .../QuerydslPredicateArgumentResolver.java | 6 +++-- .../data/querydsl/Address.java | 2 +- .../data/querydsl/QPageRequestUnitTests.java | 2 +- .../data/querydsl/QSortUnitTests.java | 25 ++++++++++--------- ...ydslRepositoryInvokerAdapterUnitTests.java | 2 +- .../SimpleEntityPathResolverUnitTests.java | 4 +-- .../springframework/data/querydsl/User.java | 2 +- .../QuerydslBindingsFactoryUnitTests.java | 6 ++--- .../binding/QuerydslBindingsUnitTests.java | 10 +++----- .../QuerydslDefaultBindingUnitTests.java | 5 ++-- .../QuerydslPredicateBuilderUnitTests.java | 12 ++++----- ...dslPredicateArgumentResolverUnitTests.java | 6 ++--- template.mf | 2 +- 29 files changed, 123 insertions(+), 95 deletions(-) diff --git a/pom.xml b/pom.xml index e0af6454e..74b071dfb 100644 --- a/pom.xml +++ b/pom.xml @@ -94,22 +94,24 @@ true + + - com.mysema.querydsl + com.querydsl querydsl-core ${querydsl} true - com.mysema.querydsl + com.querydsl querydsl-apt ${querydsl} provided - com.mysema.querydsl + com.querydsl querydsl-collections ${querydsl} true @@ -212,7 +214,7 @@ ${project.build.directory}/generated-sources/test-annotations - com.mysema.query.apt.QuerydslAnnotationProcessor + com.querydsl.apt.QuerydslAnnotationProcessor diff --git a/src/main/java/org/springframework/data/querydsl/EntityPathResolver.java b/src/main/java/org/springframework/data/querydsl/EntityPathResolver.java index d77015ce4..283d99c9a 100644 --- a/src/main/java/org/springframework/data/querydsl/EntityPathResolver.java +++ b/src/main/java/org/springframework/data/querydsl/EntityPathResolver.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"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ package org.springframework.data.querydsl; -import com.mysema.query.types.EntityPath; +import com.querydsl.core.types.EntityPath; /** * Strategy interface to abstract the ways to translate an plain domain class into a {@link EntityPath}. @@ -25,4 +25,4 @@ import com.mysema.query.types.EntityPath; public interface EntityPathResolver { EntityPath createPath(Class domainClass); -} \ No newline at end of file +} diff --git a/src/main/java/org/springframework/data/querydsl/QPageRequest.java b/src/main/java/org/springframework/data/querydsl/QPageRequest.java index e23b4e4aa..6bb97d6f7 100644 --- a/src/main/java/org/springframework/data/querydsl/QPageRequest.java +++ b/src/main/java/org/springframework/data/querydsl/QPageRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ package org.springframework.data.querydsl; import org.springframework.data.domain.AbstractPageRequest; import org.springframework.data.domain.Pageable; -import com.mysema.query.types.OrderSpecifier; +import com.querydsl.core.types.OrderSpecifier; /** * Basic Java Bean implementation of {@link Pageable} with support for QueryDSL. diff --git a/src/main/java/org/springframework/data/querydsl/QSort.java b/src/main/java/org/springframework/data/querydsl/QSort.java index 01a26ddde..2e1307155 100644 --- a/src/main/java/org/springframework/data/querydsl/QSort.java +++ b/src/main/java/org/springframework/data/querydsl/QSort.java @@ -23,12 +23,12 @@ import java.util.List; import org.springframework.data.domain.Sort; import org.springframework.util.Assert; -import com.mysema.query.types.Expression; -import com.mysema.query.types.OrderSpecifier; -import com.mysema.query.types.Path; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.OrderSpecifier; +import com.querydsl.core.types.Path; /** - * Sort option for queries that wraps a querydsl {@link OrderSpecifier}. + * Sort option for queries that wraps a Querydsl {@link OrderSpecifier}. * * @author Thomas Darimont * @author Christoph Strobl @@ -42,7 +42,7 @@ public class QSort extends Sort implements Serializable { /** * Creates a new {@link QSort} instance with the given {@link OrderSpecifier}s. * - * @param orderSpecifiers must not be {@literal null} or empty; + * @param orderSpecifiers must not be {@literal null} or empty. */ public QSort(OrderSpecifier... orderSpecifiers) { this(Arrays.asList(orderSpecifiers)); @@ -51,10 +51,12 @@ public class QSort extends Sort implements Serializable { /** * Creates a new {@link QSort} instance with the given {@link OrderSpecifier}s. * - * @param orderSpecifiers must not be {@literal null} or empty; + * @param orderSpecifiers must not be {@literal null} or empty. */ public QSort(List> orderSpecifiers) { + super(toOrders(orderSpecifiers)); + Assert.notEmpty(orderSpecifiers, "Order specifiers must not be null or empty!"); this.orderSpecifiers = orderSpecifiers; } diff --git a/src/main/java/org/springframework/data/querydsl/QueryDslPredicateExecutor.java b/src/main/java/org/springframework/data/querydsl/QueryDslPredicateExecutor.java index 92a47c0d1..9e1313c80 100644 --- a/src/main/java/org/springframework/data/querydsl/QueryDslPredicateExecutor.java +++ b/src/main/java/org/springframework/data/querydsl/QueryDslPredicateExecutor.java @@ -19,8 +19,8 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; -import com.mysema.query.types.OrderSpecifier; -import com.mysema.query.types.Predicate; +import com.querydsl.core.types.OrderSpecifier; +import com.querydsl.core.types.Predicate; /** * Interface to allow execution of QueryDsl {@link Predicate} instances. diff --git a/src/main/java/org/springframework/data/querydsl/QueryDslUtils.java b/src/main/java/org/springframework/data/querydsl/QueryDslUtils.java index 1376d7c31..f329a54ec 100644 --- a/src/main/java/org/springframework/data/querydsl/QueryDslUtils.java +++ b/src/main/java/org/springframework/data/querydsl/QueryDslUtils.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"); * you may not use this file except in compliance with the License. @@ -22,8 +22,8 @@ package org.springframework.data.querydsl; */ public abstract class QueryDslUtils { - public static final boolean QUERY_DSL_PRESENT = org.springframework.util.ClassUtils.isPresent( - "com.mysema.query.types.Predicate", QueryDslUtils.class.getClassLoader()); + public static final boolean QUERY_DSL_PRESENT = org.springframework.util.ClassUtils + .isPresent("com.querydsl.core.types.Predicate", QueryDslUtils.class.getClassLoader()); private QueryDslUtils() { diff --git a/src/main/java/org/springframework/data/querydsl/QuerydslRepositoryInvokerAdapter.java b/src/main/java/org/springframework/data/querydsl/QuerydslRepositoryInvokerAdapter.java index af8aa070a..711009e05 100644 --- a/src/main/java/org/springframework/data/querydsl/QuerydslRepositoryInvokerAdapter.java +++ b/src/main/java/org/springframework/data/querydsl/QuerydslRepositoryInvokerAdapter.java @@ -25,7 +25,7 @@ import org.springframework.data.repository.support.RepositoryInvoker; import org.springframework.util.Assert; import org.springframework.util.MultiValueMap; -import com.mysema.query.types.Predicate; +import com.querydsl.core.types.Predicate; /** * {@link RepositoryInvoker} that is aware of a {@link QueryDslPredicateExecutor} and {@link Predicate} to be executed diff --git a/src/main/java/org/springframework/data/querydsl/SimpleEntityPathResolver.java b/src/main/java/org/springframework/data/querydsl/SimpleEntityPathResolver.java index 8e16beb9a..ff6ee89ae 100644 --- a/src/main/java/org/springframework/data/querydsl/SimpleEntityPathResolver.java +++ b/src/main/java/org/springframework/data/querydsl/SimpleEntityPathResolver.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"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ import java.lang.reflect.Modifier; import org.springframework.util.ClassUtils; import org.springframework.util.ReflectionUtils; -import com.mysema.query.types.EntityPath; +import com.querydsl.core.types.EntityPath; /** * Simple implementation of {@link EntityPathResolver} to lookup a query class by reflection and using the static field @@ -116,4 +116,4 @@ public enum SimpleEntityPathResolver implements EntityPathResolver { return parts[0] + "_"; } -} \ No newline at end of file +} diff --git a/src/main/java/org/springframework/data/querydsl/binding/MultiValueBinding.java b/src/main/java/org/springframework/data/querydsl/binding/MultiValueBinding.java index 24ed4b900..00fbe8709 100644 --- a/src/main/java/org/springframework/data/querydsl/binding/MultiValueBinding.java +++ b/src/main/java/org/springframework/data/querydsl/binding/MultiValueBinding.java @@ -17,8 +17,8 @@ package org.springframework.data.querydsl.binding; import java.util.Collection; -import com.mysema.query.types.Path; -import com.mysema.query.types.Predicate; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.Predicate; /** * {@link MultiValueBinding} creates a {@link Predicate} out of given {@link Path} and collection value. Used for @@ -31,13 +31,14 @@ import com.mysema.query.types.Predicate; public interface MultiValueBinding, S> { /** - * Returns the predicate to be applied to the given {@link Path} for the given collection value, which will contain - * all values submitted for the path bind. If a single value was provided only the collection will consist of exactly - * one element. + * Returns the predicate to be applied to the given {@link Path} for the given collection value, which will contain + * all values submitted for the path bind. If a single value was provided only the collection will consist of exactly + * one element. * * @param path {@link Path} to the property. Will not be {@literal null}. * @param value the value that should be bound. Will not be {@literal null} or empty. - * @return can be {@literal null}, in which case the binding will not be incorporated in the overall {@link Predicate}. + * @return can be {@literal null}, in which case the binding will not be incorporated in the overall {@link Predicate} + * . */ Predicate bind(T path, Collection value); } diff --git a/src/main/java/org/springframework/data/querydsl/binding/QuerydslBinderCustomizer.java b/src/main/java/org/springframework/data/querydsl/binding/QuerydslBinderCustomizer.java index 62369f9e5..bec468fb8 100644 --- a/src/main/java/org/springframework/data/querydsl/binding/QuerydslBinderCustomizer.java +++ b/src/main/java/org/springframework/data/querydsl/binding/QuerydslBinderCustomizer.java @@ -15,14 +15,21 @@ */ package org.springframework.data.querydsl.binding; -import com.mysema.query.types.EntityPath; +import com.querydsl.core.types.EntityPath; /** * A component that will customize {@link QuerydslBindings} for the given entity path. * * @author Oliver Gierke + * @since 1.11 */ public interface QuerydslBinderCustomizer> { + /** + * Customize the {@link QuerydslBindings} for the given root. + * + * @param bindings the {@link QuerydslBindings} to customize, will never be {@literal null}. + * @param root the entity root, will never be {@literal null}. + */ void customize(QuerydslBindings bindings, T root); } diff --git a/src/main/java/org/springframework/data/querydsl/binding/QuerydslBindings.java b/src/main/java/org/springframework/data/querydsl/binding/QuerydslBindings.java index ad8da4cf4..7b0f4456b 100644 --- a/src/main/java/org/springframework/data/querydsl/binding/QuerydslBindings.java +++ b/src/main/java/org/springframework/data/querydsl/binding/QuerydslBindings.java @@ -28,9 +28,9 @@ import org.springframework.data.mapping.PropertyPath; import org.springframework.util.Assert; import org.springframework.util.StringUtils; -import com.mysema.query.types.Path; -import com.mysema.query.types.PathMetadata; -import com.mysema.query.types.Predicate; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.Predicate; /** * {@link QuerydslBindings} allows definition of path specific {@link SingleValueBinding}. @@ -229,9 +229,9 @@ public class QuerydslBindings { return ""; } - PathMetadata metadata = path.getMetadata(); + PathMetadata metadata = path.getMetadata(); - return path.toString().substring(metadata.getRoot().getMetadata().getName().length() + 1); + return path.toString().substring(metadata.getRootPath().getMetadata().getName().length() + 1); } /** diff --git a/src/main/java/org/springframework/data/querydsl/binding/QuerydslBindingsFactory.java b/src/main/java/org/springframework/data/querydsl/binding/QuerydslBindingsFactory.java index 1718683e5..1261daaad 100644 --- a/src/main/java/org/springframework/data/querydsl/binding/QuerydslBindingsFactory.java +++ b/src/main/java/org/springframework/data/querydsl/binding/QuerydslBindingsFactory.java @@ -29,10 +29,13 @@ import org.springframework.data.util.TypeInformation; import org.springframework.util.Assert; import org.springframework.util.ConcurrentReferenceHashMap; -import com.mysema.query.types.EntityPath; +import com.querydsl.core.types.EntityPath; /** + * Factory to create {@link QuerydslBindings} using an {@link EntityPathResolver}. + * * @author Oliver Gierke + * @since 1.11 */ public class QuerydslBindingsFactory implements ApplicationContextAware { @@ -45,6 +48,8 @@ public class QuerydslBindingsFactory implements ApplicationContextAware { private Repositories repositories; /** + * Creates a new {@link QuerydslBindingsFactory} using the given {@link EntityPathResolver}. + * * @param entityPathResolver must not be {@literal null}. */ public QuerydslBindingsFactory(EntityPathResolver entityPathResolver) { @@ -61,6 +66,7 @@ public class QuerydslBindingsFactory implements ApplicationContextAware { */ @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + this.beanFactory = applicationContext.getAutowireCapableBeanFactory(); this.repositories = new Repositories(applicationContext); } @@ -74,9 +80,20 @@ public class QuerydslBindingsFactory implements ApplicationContextAware { return entityPathResolver; } - public QuerydslBindings createBindingsFor(Class customizer, + /** + * Creates the {@link QuerydslBindings} to be used using for the given domain type and a pre-defined + * {@link QuerydslBinderCustomizer}. If no customizer is given, auto-detection will be applied. + * + * @param customizer the {@link QuerydslBinderCustomizer} to use. If {@literal null} is given customizer detection for + * the given domain type will be applied. + * @param domainType must not be {@literal null}. + * @return + */ + public QuerydslBindings createBindingsFor(Class> customizer, TypeInformation domainType) { + Assert.notNull(domainType, "Domain type must not be null!"); + EntityPath path = verifyEntityPathPresent(domainType); QuerydslBindings bindings = new QuerydslBindings(); diff --git a/src/main/java/org/springframework/data/querydsl/binding/QuerydslDefaultBinding.java b/src/main/java/org/springframework/data/querydsl/binding/QuerydslDefaultBinding.java index 41b887860..e76d6294c 100644 --- a/src/main/java/org/springframework/data/querydsl/binding/QuerydslDefaultBinding.java +++ b/src/main/java/org/springframework/data/querydsl/binding/QuerydslDefaultBinding.java @@ -19,11 +19,11 @@ import java.util.Collection; import org.springframework.util.Assert; -import com.mysema.query.BooleanBuilder; -import com.mysema.query.types.Path; -import com.mysema.query.types.Predicate; -import com.mysema.query.types.expr.SimpleExpression; -import com.mysema.query.types.path.CollectionPathBase; +import com.querydsl.core.BooleanBuilder; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.Predicate; +import com.querydsl.core.types.dsl.CollectionPathBase; +import com.querydsl.core.types.dsl.SimpleExpression; /** * Default implementation of {@link MultiValueBinding} creating {@link Predicate} based on the {@link Path}s type. diff --git a/src/main/java/org/springframework/data/querydsl/binding/QuerydslPredicateBuilder.java b/src/main/java/org/springframework/data/querydsl/binding/QuerydslPredicateBuilder.java index ee2f05117..a41af02e7 100644 --- a/src/main/java/org/springframework/data/querydsl/binding/QuerydslPredicateBuilder.java +++ b/src/main/java/org/springframework/data/querydsl/binding/QuerydslPredicateBuilder.java @@ -39,9 +39,9 @@ import org.springframework.util.MultiValueMap; import org.springframework.util.ReflectionUtils; import org.springframework.util.StringUtils; -import com.mysema.query.BooleanBuilder; -import com.mysema.query.types.Path; -import com.mysema.query.types.Predicate; +import com.querydsl.core.BooleanBuilder; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.Predicate; /** * Builder assembling {@link Predicate} out of {@link PropertyValues}. diff --git a/src/main/java/org/springframework/data/querydsl/binding/SingleValueBinding.java b/src/main/java/org/springframework/data/querydsl/binding/SingleValueBinding.java index 5996411da..67ff567c8 100644 --- a/src/main/java/org/springframework/data/querydsl/binding/SingleValueBinding.java +++ b/src/main/java/org/springframework/data/querydsl/binding/SingleValueBinding.java @@ -15,8 +15,8 @@ */ package org.springframework.data.querydsl.binding; -import com.mysema.query.types.Path; -import com.mysema.query.types.Predicate; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.Predicate; /** * {@link SingleValueBinding} creates a {@link Predicate} out of given {@link Path} and value. Used for specific @@ -30,12 +30,13 @@ import com.mysema.query.types.Predicate; public interface SingleValueBinding, S> { /** - * Returns the predicate to be applied to the given {@link Path} for the given value. The given value will be the first - * the first one provided for the given path and converted into the expected type. + * Returns the predicate to be applied to the given {@link Path} for the given value. The given value will be the + * first the first one provided for the given path and converted into the expected type. * * @param path {@link Path} to the property. Will not be {@literal null}. * @param value the value that should be bound. Will not be {@literal null}. - * @return can be {@literal null}, in which case the binding will not be incorporated in the overall {@link Predicate}. + * @return can be {@literal null}, in which case the binding will not be incorporated in the overall {@link Predicate} + * . */ Predicate bind(T path, S value); } diff --git a/src/main/java/org/springframework/data/web/config/QuerydslWebConfiguration.java b/src/main/java/org/springframework/data/web/config/QuerydslWebConfiguration.java index 7078ccc5f..f17804363 100644 --- a/src/main/java/org/springframework/data/web/config/QuerydslWebConfiguration.java +++ b/src/main/java/org/springframework/data/web/config/QuerydslWebConfiguration.java @@ -30,7 +30,7 @@ import org.springframework.data.web.querydsl.QuerydslPredicateArgumentResolver; import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; -import com.mysema.query.types.Predicate; +import com.querydsl.core.types.Predicate; /** * Querydsl-specific web configuration for Spring Data. Registers a {@link HandlerMethodArgumentResolver} that builds up diff --git a/src/main/java/org/springframework/data/web/querydsl/QuerydslPredicateArgumentResolver.java b/src/main/java/org/springframework/data/web/querydsl/QuerydslPredicateArgumentResolver.java index 2a2395acc..031958ed0 100644 --- a/src/main/java/org/springframework/data/web/querydsl/QuerydslPredicateArgumentResolver.java +++ b/src/main/java/org/springframework/data/web/querydsl/QuerydslPredicateArgumentResolver.java @@ -35,7 +35,7 @@ import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.method.support.ModelAndViewContainer; -import com.mysema.query.types.Predicate; +import com.querydsl.core.types.Predicate; /** * {@link HandlerMethodArgumentResolver} to allow injection of {@link com.mysema.query.types.Predicate} into Spring MVC @@ -88,6 +88,7 @@ public class QuerydslPredicateArgumentResolver implements HandlerMethodArgumentR * @see org.springframework.web.method.support.HandlerMethodArgumentResolver#resolveArgument(org.springframework.core.MethodParameter, org.springframework.web.method.support.ModelAndViewContainer, org.springframework.web.context.request.NativeWebRequest, org.springframework.web.bind.support.WebDataBinderFactory) */ @Override + @SuppressWarnings("unchecked") public Predicate resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { @@ -100,7 +101,8 @@ public class QuerydslPredicateArgumentResolver implements HandlerMethodArgumentR QuerydslPredicate annotation = parameter.getParameterAnnotation(QuerydslPredicate.class); TypeInformation domainType = extractTypeInfo(parameter).getActualType(); - Class customizer = annotation == null ? null : annotation.bindings(); + Class> customizer = (Class>) (annotation == null + ? null : annotation.bindings()); QuerydslBindings bindings = bindingsFactory.createBindingsFor(customizer, domainType); return predicateBuilder.getPredicate(domainType, parameters, bindings); diff --git a/src/test/java/org/springframework/data/querydsl/Address.java b/src/test/java/org/springframework/data/querydsl/Address.java index 60ce4510c..0cbaea323 100644 --- a/src/test/java/org/springframework/data/querydsl/Address.java +++ b/src/test/java/org/springframework/data/querydsl/Address.java @@ -15,7 +15,7 @@ */ package org.springframework.data.querydsl; -import com.mysema.query.annotations.QueryEntity; +import com.querydsl.core.annotations.QueryEntity; /** * @author Christoph Strobl diff --git a/src/test/java/org/springframework/data/querydsl/QPageRequestUnitTests.java b/src/test/java/org/springframework/data/querydsl/QPageRequestUnitTests.java index f4db5e843..e4577a19d 100644 --- a/src/test/java/org/springframework/data/querydsl/QPageRequestUnitTests.java +++ b/src/test/java/org/springframework/data/querydsl/QPageRequestUnitTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/springframework/data/querydsl/QSortUnitTests.java b/src/test/java/org/springframework/data/querydsl/QSortUnitTests.java index c9c7454e2..f35b39689 100644 --- a/src/test/java/org/springframework/data/querydsl/QSortUnitTests.java +++ b/src/test/java/org/springframework/data/querydsl/QSortUnitTests.java @@ -29,9 +29,10 @@ import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort.Direction; import org.springframework.data.domain.Sort.Order; -import com.mysema.query.annotations.QueryInit; -import com.mysema.query.types.OrderSpecifier; -import com.mysema.query.types.path.StringPath; +import com.querydsl.core.annotations.QueryInit; +import com.querydsl.core.types.OrderSpecifier; +import com.querydsl.core.types.dsl.PathBuilderFactory; +import com.querydsl.core.types.dsl.StringPath; /** * Unit tests for {@link QSort}. @@ -164,10 +165,8 @@ public class QSortUnitTests { Sort result = sort.and(new Sort(Direction.ASC, "lastname")); assertThat(result, is(Matchers. iterableWithSize(2))); - assertThat( - result, - hasItems(new Order(Direction.ASC, "lastname"), - new Order(Direction.ASC, user.dateOfBirth.yearMonth().toString()))); + assertThat(result, hasItems(new Order(Direction.ASC, "lastname"), + new Order(Direction.ASC, user.dateOfBirth.yearMonth().toString()))); } /** @@ -209,23 +208,25 @@ public class QSortUnitTests { @Test public void handlesPlainStringPathsCorrectly() { - QSort sort = new QSort(new OrderSpecifier(com.mysema.query.types.Order.ASC, new StringPath("firstname"))); + StringPath path = new PathBuilderFactory().create(User.class).getString("firstname"); + + QSort sort = new QSort(new OrderSpecifier(com.querydsl.core.types.Order.ASC, path)); assertThat(sort, hasItems(new Order(Direction.ASC, "firstname"))); } - @com.mysema.query.annotations.QueryEntity + @com.querydsl.core.annotations.QueryEntity static class WrapperToWrapWrapperForUserWrapper { - @QueryInit("wrapper.user")// + @QueryInit("wrapper.user") // WrapperForUserWrapper wrapperForUserWrapper; - @com.mysema.query.annotations.QueryEntity + @com.querydsl.core.annotations.QueryEntity static class WrapperForUserWrapper { UserWrapper wrapper; - @com.mysema.query.annotations.QueryEntity + @com.querydsl.core.annotations.QueryEntity static class UserWrapper { User user; diff --git a/src/test/java/org/springframework/data/querydsl/QuerydslRepositoryInvokerAdapterUnitTests.java b/src/test/java/org/springframework/data/querydsl/QuerydslRepositoryInvokerAdapterUnitTests.java index f79b743a8..188954ef4 100644 --- a/src/test/java/org/springframework/data/querydsl/QuerydslRepositoryInvokerAdapterUnitTests.java +++ b/src/test/java/org/springframework/data/querydsl/QuerydslRepositoryInvokerAdapterUnitTests.java @@ -33,7 +33,7 @@ import org.springframework.data.domain.Sort; import org.springframework.data.repository.support.RepositoryInvoker; import org.springframework.util.MultiValueMap; -import com.mysema.query.types.Predicate; +import com.querydsl.core.types.Predicate; /** * Unit tests for {@link QuerydslRepositoryInvokerAdapter}. diff --git a/src/test/java/org/springframework/data/querydsl/SimpleEntityPathResolverUnitTests.java b/src/test/java/org/springframework/data/querydsl/SimpleEntityPathResolverUnitTests.java index 30ee72256..a1be959a6 100644 --- a/src/test/java/org/springframework/data/querydsl/SimpleEntityPathResolverUnitTests.java +++ b/src/test/java/org/springframework/data/querydsl/SimpleEntityPathResolverUnitTests.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"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import static org.junit.Assert.*; import org.junit.Test; -import com.mysema.query.annotations.QueryEntity; +import com.querydsl.core.annotations.QueryEntity; /** * Unit test for {@link SimpleEntityPathResolver}. diff --git a/src/test/java/org/springframework/data/querydsl/User.java b/src/test/java/org/springframework/data/querydsl/User.java index fd12adae0..fc8083caf 100644 --- a/src/test/java/org/springframework/data/querydsl/User.java +++ b/src/test/java/org/springframework/data/querydsl/User.java @@ -21,7 +21,7 @@ import java.util.List; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat.ISO; -import com.mysema.query.annotations.QueryEntity; +import com.querydsl.core.annotations.QueryEntity; /** * @author Oliver Gierke diff --git a/src/test/java/org/springframework/data/querydsl/binding/QuerydslBindingsFactoryUnitTests.java b/src/test/java/org/springframework/data/querydsl/binding/QuerydslBindingsFactoryUnitTests.java index 69dd1ec18..4e2d3228d 100644 --- a/src/test/java/org/springframework/data/querydsl/binding/QuerydslBindingsFactoryUnitTests.java +++ b/src/test/java/org/springframework/data/querydsl/binding/QuerydslBindingsFactoryUnitTests.java @@ -36,9 +36,9 @@ import org.springframework.data.util.TypeInformation; import org.springframework.test.util.ReflectionTestUtils; import org.springframework.web.servlet.ModelAndView; -import com.mysema.query.types.Path; -import com.mysema.query.types.Predicate; -import com.mysema.query.types.path.StringPath; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.Predicate; +import com.querydsl.core.types.dsl.StringPath; /** * Unit tests for {@link QuerydslBindingsFactory}. diff --git a/src/test/java/org/springframework/data/querydsl/binding/QuerydslBindingsUnitTests.java b/src/test/java/org/springframework/data/querydsl/binding/QuerydslBindingsUnitTests.java index 4be21425f..d4f8a2cee 100644 --- a/src/test/java/org/springframework/data/querydsl/binding/QuerydslBindingsUnitTests.java +++ b/src/test/java/org/springframework/data/querydsl/binding/QuerydslBindingsUnitTests.java @@ -25,15 +25,11 @@ import org.springframework.data.mapping.PropertyPath; import org.springframework.data.querydsl.QUser; import org.springframework.data.querydsl.SimpleEntityPathResolver; import org.springframework.data.querydsl.User; -import org.springframework.data.querydsl.binding.MultiValueBinding; -import org.springframework.data.querydsl.binding.QuerydslBindings; -import org.springframework.data.querydsl.binding.QuerydslPredicateBuilder; -import org.springframework.data.querydsl.binding.SingleValueBinding; import org.springframework.test.util.ReflectionTestUtils; -import com.mysema.query.types.Path; -import com.mysema.query.types.Predicate; -import com.mysema.query.types.path.StringPath; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.Predicate; +import com.querydsl.core.types.dsl.StringPath; /** * Unit tests for {@link QuerydslBindings}. diff --git a/src/test/java/org/springframework/data/querydsl/binding/QuerydslDefaultBindingUnitTests.java b/src/test/java/org/springframework/data/querydsl/binding/QuerydslDefaultBindingUnitTests.java index 062234219..043f46977 100644 --- a/src/test/java/org/springframework/data/querydsl/binding/QuerydslDefaultBindingUnitTests.java +++ b/src/test/java/org/springframework/data/querydsl/binding/QuerydslDefaultBindingUnitTests.java @@ -27,10 +27,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.springframework.data.querydsl.QUser; -import org.springframework.data.querydsl.binding.QuerydslDefaultBinding; -import com.mysema.query.types.Expression; -import com.mysema.query.types.Predicate; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.Predicate; /** * @author Christoph Strobl diff --git a/src/test/java/org/springframework/data/querydsl/binding/QuerydslPredicateBuilderUnitTests.java b/src/test/java/org/springframework/data/querydsl/binding/QuerydslPredicateBuilderUnitTests.java index 5e7583d26..fcc1421b8 100644 --- a/src/test/java/org/springframework/data/querydsl/binding/QuerydslPredicateBuilderUnitTests.java +++ b/src/test/java/org/springframework/data/querydsl/binding/QuerydslPredicateBuilderUnitTests.java @@ -36,10 +36,10 @@ import org.springframework.format.support.DefaultFormattingConversionService; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; -import com.mysema.query.collections.CollQueryFactory; -import com.mysema.query.types.Constant; -import com.mysema.query.types.Predicate; -import com.mysema.query.types.path.StringPath; +import com.querydsl.collections.CollQueryFactory; +import com.querydsl.core.types.Constant; +import com.querydsl.core.types.Predicate; +import com.querydsl.core.types.dsl.StringPath; /** * Unit tests for {@link QuerydslPredicateBuilder}. @@ -99,7 +99,7 @@ public class QuerydslPredicateBuilderUnitTests { assertThat(predicate, is((Predicate) QUser.user.firstname.eq("Oliver"))); - List result = CollQueryFactory.from(QUser.user, Users.USERS).where(predicate).list(QUser.user); + List result = CollQueryFactory.from(QUser.user, Users.USERS).where(predicate).fetchResults().getResults(); assertThat(result, hasSize(1)); assertThat(result, hasItem(Users.OLIVER)); @@ -117,7 +117,7 @@ public class QuerydslPredicateBuilderUnitTests { assertThat(predicate, is((Predicate) QUser.user.address.city.eq("Linz"))); - List result = CollQueryFactory.from(QUser.user, Users.USERS).where(predicate).list(QUser.user); + List result = CollQueryFactory.from(QUser.user, Users.USERS).where(predicate).fetchResults().getResults(); assertThat(result, hasSize(1)); assertThat(result, hasItem(Users.CHRISTOPH)); diff --git a/src/test/java/org/springframework/data/web/querydsl/QuerydslPredicateArgumentResolverUnitTests.java b/src/test/java/org/springframework/data/web/querydsl/QuerydslPredicateArgumentResolverUnitTests.java index 98baeb3a6..2b22616a4 100644 --- a/src/test/java/org/springframework/data/web/querydsl/QuerydslPredicateArgumentResolverUnitTests.java +++ b/src/test/java/org/springframework/data/web/querydsl/QuerydslPredicateArgumentResolverUnitTests.java @@ -44,9 +44,9 @@ import org.springframework.test.util.ReflectionTestUtils; import org.springframework.web.context.request.ServletWebRequest; import org.springframework.web.servlet.ModelAndView; -import com.mysema.query.types.Predicate; -import com.mysema.query.types.expr.BooleanExpression; -import com.mysema.query.types.path.StringPath; +import com.querydsl.core.types.Predicate; +import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.core.types.dsl.StringPath; /** * Unit tests for {@link QuerydslPredicateArgumentResolver}. diff --git a/template.mf b/template.mf index be51625fa..25fdcdf93 100644 --- a/template.mf +++ b/template.mf @@ -8,8 +8,8 @@ Import-Package: sun.reflect;version="0";resolution:=optional Import-Template: com.fasterxml.jackson.*;version="${jackson:[=.=.=,+1.0.0)}";resolution:=optional, - com.mysema.query.*;version="${querydsl:[=.=.=,+1.0.0)}";resolution:=optional, com.google.common.*;version="${guava:[=.=.=,+1.0.0)}";resolution:=optional, + com.querydsl.*;version="${querydsl:[=.=.=,+1.0.0)}";resolution:=optional, javax.enterprise.*;version="${cdi:[=.=.=,+1.0.0)}";resolution:=optional, javax.inject.*;version="[1.0.0,2.0.0)";resolution:=optional, javax.xml.bind.*;version="0";resolution:=optional,