diff --git a/pom.xml b/pom.xml index febef7ea8..9954d5ce0 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,6 @@ 1.8.0.10 2.0.0 2.4.0 - 3.6.3 1.12.0.BUILD-SNAPSHOT reuseReports @@ -223,14 +222,14 @@ - com.mysema.querydsl + com.querydsl querydsl-apt ${querydsl} provided - com.mysema.querydsl + com.querydsl querydsl-jpa ${querydsl} true @@ -424,7 +423,7 @@ true - com.mysema.query.apt.jpa.JPAAnnotationProcessor + com.querydsl.apt.jpa.JPAAnnotationProcessor org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor diff --git a/src/main/java/org/springframework/data/jpa/repository/support/QueryDslJpaRepository.java b/src/main/java/org/springframework/data/jpa/repository/support/QueryDslJpaRepository.java index 05613f689..c7cc18d79 100644 --- a/src/main/java/org/springframework/data/jpa/repository/support/QueryDslJpaRepository.java +++ b/src/main/java/org/springframework/data/jpa/repository/support/QueryDslJpaRepository.java @@ -32,12 +32,12 @@ import org.springframework.data.querydsl.QSort; import org.springframework.data.querydsl.QueryDslPredicateExecutor; import org.springframework.data.querydsl.SimpleEntityPathResolver; -import com.mysema.query.jpa.JPQLQuery; -import com.mysema.query.jpa.impl.JPAQuery; -import com.mysema.query.types.EntityPath; -import com.mysema.query.types.OrderSpecifier; -import com.mysema.query.types.Predicate; -import com.mysema.query.types.path.PathBuilder; +import com.querydsl.core.types.EntityPath; +import com.querydsl.core.types.OrderSpecifier; +import com.querydsl.core.types.Predicate; +import com.querydsl.core.types.dsl.PathBuilder; +import com.querydsl.jpa.JPQLQuery; +import com.querydsl.jpa.impl.AbstractJPAQuery; /** * QueryDsl specific extension of {@link SimpleJpaRepository} which adds implementation for @@ -46,8 +46,8 @@ import com.mysema.query.types.path.PathBuilder; * @author Oliver Gierke * @author Thomas Darimont */ -public class QueryDslJpaRepository extends SimpleJpaRepository implements - QueryDslPredicateExecutor { +public class QueryDslJpaRepository extends SimpleJpaRepository + implements QueryDslPredicateExecutor { private static final EntityPathResolver DEFAULT_ENTITY_PATH_RESOLVER = SimpleEntityPathResolver.INSTANCE; @@ -78,6 +78,7 @@ public class QueryDslJpaRepository extends SimpleJpa EntityPathResolver resolver) { super(entityInformation, entityManager); + this.path = resolver.createPath(entityInformation.getJavaType()); this.builder = new PathBuilder(path.getType(), path.getMetadata()); this.querydsl = new Querydsl(entityManager, builder); @@ -89,7 +90,7 @@ public class QueryDslJpaRepository extends SimpleJpa */ @Override public T findOne(Predicate predicate) { - return createQuery(predicate).uniqueResult(path); + return createQuery(predicate).select(path).fetchOne(); } /* @@ -98,7 +99,7 @@ public class QueryDslJpaRepository extends SimpleJpa */ @Override public List findAll(Predicate predicate) { - return createQuery(predicate).list(path); + return createQuery(predicate).select(path).fetch(); } /* @@ -107,7 +108,7 @@ public class QueryDslJpaRepository extends SimpleJpa */ @Override public List findAll(Predicate predicate, OrderSpecifier... orders) { - return executeSorted(createQuery(predicate), orders); + return executeSorted(createQuery(predicate).select(path), orders); } /* @@ -116,7 +117,7 @@ public class QueryDslJpaRepository extends SimpleJpa */ @Override public List findAll(Predicate predicate, Sort sort) { - return executeSorted(createQuery(predicate), sort); + return executeSorted(createQuery(predicate).select(path), sort); } /* @@ -125,7 +126,7 @@ public class QueryDslJpaRepository extends SimpleJpa */ @Override public List findAll(OrderSpecifier... orders) { - return executeSorted(createQuery(new Predicate[0]), orders); + return executeSorted(createQuery(new Predicate[0]).select(path), orders); } /* @@ -135,11 +136,11 @@ public class QueryDslJpaRepository extends SimpleJpa @Override public Page findAll(Predicate predicate, Pageable pageable) { - JPQLQuery countQuery = createQuery(predicate); - JPQLQuery query = querydsl.applyPagination(pageable, createQuery(predicate)); + JPQLQuery countQuery = createQuery(predicate); + JPQLQuery query = querydsl.applyPagination(pageable, createQuery(predicate).select(path)); - Long total = countQuery.count(); - List content = pageable == null || total > pageable.getOffset() ? query.list(path) : Collections. emptyList(); + long total = countQuery.fetchCount(); + List content = pageable == null || total > pageable.getOffset() ? query.fetch() : Collections. emptyList(); return new PageImpl(content, pageable, total); } @@ -150,7 +151,7 @@ public class QueryDslJpaRepository extends SimpleJpa */ @Override public long count(Predicate predicate) { - return createQuery(predicate).count(); + return createQuery(predicate).fetchCount(); } /* @@ -159,7 +160,7 @@ public class QueryDslJpaRepository extends SimpleJpa */ @Override public boolean exists(Predicate predicate) { - return createQuery(predicate).exists(); + return createQuery(predicate).fetchCount() > 0; } /** @@ -168,9 +169,9 @@ public class QueryDslJpaRepository extends SimpleJpa * @param predicate * @return the Querydsl {@link JPQLQuery}. */ - protected JPQLQuery createQuery(Predicate... predicate) { + protected JPQLQuery createQuery(Predicate... predicate) { - JPAQuery query = querydsl.createQuery(path).where(predicate); + AbstractJPAQuery query = querydsl.createQuery(path).where(predicate); CrudMethodMetadata metadata = getRepositoryMethodMetadata(); if (metadata == null) { @@ -194,7 +195,7 @@ public class QueryDslJpaRepository extends SimpleJpa * @param orders must not be {@literal null}. * @return */ - private List executeSorted(JPQLQuery query, OrderSpecifier... orders) { + private List executeSorted(JPQLQuery query, OrderSpecifier... orders) { return executeSorted(query, new QSort(orders)); } @@ -205,7 +206,7 @@ public class QueryDslJpaRepository extends SimpleJpa * @param sort must not be {@literal null}. * @return */ - private List executeSorted(JPQLQuery query, Sort sort) { - return querydsl.applySorting(sort, query).list(path); + private List executeSorted(JPQLQuery query, Sort sort) { + return querydsl.applySorting(sort, query).fetch(); } } diff --git a/src/main/java/org/springframework/data/jpa/repository/support/QueryDslRepositorySupport.java b/src/main/java/org/springframework/data/jpa/repository/support/QueryDslRepositorySupport.java index 878bac417..22a4fef89 100644 --- a/src/main/java/org/springframework/data/jpa/repository/support/QueryDslRepositorySupport.java +++ b/src/main/java/org/springframework/data/jpa/repository/support/QueryDslRepositorySupport.java @@ -22,14 +22,14 @@ import javax.persistence.PersistenceContext; import org.springframework.stereotype.Repository; import org.springframework.util.Assert; -import com.mysema.query.dml.DeleteClause; -import com.mysema.query.dml.UpdateClause; -import com.mysema.query.jpa.JPQLQuery; -import com.mysema.query.jpa.impl.JPADeleteClause; -import com.mysema.query.jpa.impl.JPAUpdateClause; -import com.mysema.query.types.EntityPath; -import com.mysema.query.types.path.PathBuilder; -import com.mysema.query.types.path.PathBuilderFactory; +import com.querydsl.core.dml.DeleteClause; +import com.querydsl.core.dml.UpdateClause; +import com.querydsl.core.types.EntityPath; +import com.querydsl.core.types.dsl.PathBuilder; +import com.querydsl.core.types.dsl.PathBuilderFactory; +import com.querydsl.jpa.JPQLQuery; +import com.querydsl.jpa.impl.JPADeleteClause; +import com.querydsl.jpa.impl.JPAUpdateClause; /** * Base class for implementing repositories using QueryDsl library. @@ -88,12 +88,23 @@ public abstract class QueryDslRepositorySupport { /** * Returns a fresh {@link JPQLQuery}. * + * @param path must not be {@literal null}. * @return the Querydsl {@link JPQLQuery}. */ - protected JPQLQuery from(EntityPath... paths) { + protected JPQLQuery from(EntityPath... paths) { return querydsl.createQuery(paths); } + /** + * Returns a {@link JPQLQuery} for the given {@link EntityPath}. + * + * @param path must not be {@literal null}. + * @return + */ + protected JPQLQuery from(EntityPath path) { + return querydsl.createQuery(path).select(path); + } + /** * Returns a fresh {@link DeleteClause}. * diff --git a/src/main/java/org/springframework/data/jpa/repository/support/Querydsl.java b/src/main/java/org/springframework/data/jpa/repository/support/Querydsl.java index 9051a2cc6..5e33031ed 100644 --- a/src/main/java/org/springframework/data/jpa/repository/support/Querydsl.java +++ b/src/main/java/org/springframework/data/jpa/repository/support/Querydsl.java @@ -27,19 +27,19 @@ import org.springframework.data.mapping.PropertyPath; import org.springframework.data.querydsl.QSort; import org.springframework.util.Assert; -import com.mysema.query.jpa.EclipseLinkTemplates; -import com.mysema.query.jpa.HQLTemplates; -import com.mysema.query.jpa.JPQLQuery; -import com.mysema.query.jpa.OpenJPATemplates; -import com.mysema.query.jpa.impl.AbstractJPAQuery; -import com.mysema.query.jpa.impl.JPAQuery; -import com.mysema.query.support.Expressions; -import com.mysema.query.types.EntityPath; -import com.mysema.query.types.Expression; -import com.mysema.query.types.OrderSpecifier; -import com.mysema.query.types.OrderSpecifier.NullHandling; -import com.mysema.query.types.Path; -import com.mysema.query.types.path.PathBuilder; +import com.querydsl.core.types.EntityPath; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.OrderSpecifier; +import com.querydsl.core.types.OrderSpecifier.NullHandling; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.dsl.Expressions; +import com.querydsl.core.types.dsl.PathBuilder; +import com.querydsl.jpa.EclipseLinkTemplates; +import com.querydsl.jpa.HQLTemplates; +import com.querydsl.jpa.JPQLQuery; +import com.querydsl.jpa.OpenJPATemplates; +import com.querydsl.jpa.impl.AbstractJPAQuery; +import com.querydsl.jpa.impl.JPAQuery; /** * Helper instance to ease access to Querydsl JPA query API. @@ -74,18 +74,18 @@ public class Querydsl { * * @return */ - public AbstractJPAQuery createQuery() { + public AbstractJPAQuery> createQuery() { switch (provider) { case ECLIPSELINK: - return new JPAQuery(em, EclipseLinkTemplates.DEFAULT); + return new JPAQuery(em, EclipseLinkTemplates.DEFAULT); case HIBERNATE: - return new JPAQuery(em, HQLTemplates.DEFAULT); + return new JPAQuery(em, HQLTemplates.DEFAULT); case OPEN_JPA: - return new JPAQuery(em, OpenJPATemplates.DEFAULT); + return new JPAQuery(em, OpenJPATemplates.DEFAULT); case GENERIC_JPA: default: - return new JPAQuery(em); + return new JPAQuery(em); } } @@ -94,7 +94,7 @@ public class Querydsl { * * @return */ - public AbstractJPAQuery createQuery(EntityPath... paths) { + public AbstractJPAQuery> createQuery(EntityPath... paths) { return createQuery().from(paths); } @@ -105,7 +105,7 @@ public class Querydsl { * @param query must not be {@literal null}. * @return the Querydsl {@link JPQLQuery}. */ - public JPQLQuery applyPagination(Pageable pageable, JPQLQuery query) { + public JPQLQuery applyPagination(Pageable pageable, JPQLQuery query) { if (pageable == null) { return query; @@ -124,7 +124,7 @@ public class Querydsl { * @param query must not be {@literal null}. * @return the Querydsl {@link JPQLQuery} */ - public JPQLQuery applySorting(Sort sort, JPQLQuery query) { + public JPQLQuery applySorting(Sort sort, JPQLQuery query) { if (sort == null) { return query; @@ -144,8 +144,7 @@ public class Querydsl { * @param qsort must not be {@literal null}. * @param query must not be {@literal null}. */ - - private JPQLQuery addOrderByFrom(QSort qsort, JPQLQuery query) { + private JPQLQuery addOrderByFrom(QSort qsort, JPQLQuery query) { List> orderSpecifiers = qsort.getOrderSpecifiers(); return query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()])); @@ -159,7 +158,7 @@ public class Querydsl { * @param query must not be {@literal null}. * @return */ - private JPQLQuery addOrderByFrom(Sort sort, JPQLQuery query) { + private JPQLQuery addOrderByFrom(Sort sort, JPQLQuery query) { Assert.notNull(sort, "Sort must not be null!"); Assert.notNull(query, "Query must not be null!"); @@ -180,9 +179,9 @@ public class Querydsl { @SuppressWarnings({ "rawtypes", "unchecked" }) private OrderSpecifier toOrderSpecifier(Order order) { - return new OrderSpecifier(order.isAscending() ? com.mysema.query.types.Order.ASC - : com.mysema.query.types.Order.DESC, buildOrderPropertyPathFrom(order), - toQueryDslNullHandling(order.getNullHandling())); + return new OrderSpecifier( + order.isAscending() ? com.querydsl.core.types.Order.ASC : com.querydsl.core.types.Order.DESC, + buildOrderPropertyPathFrom(order), toQueryDslNullHandling(order.getNullHandling())); } /** diff --git a/src/test/java/org/springframework/data/jpa/repository/CrudMethodMetadataUnitTests.java b/src/test/java/org/springframework/data/jpa/repository/CrudMethodMetadataUnitTests.java index 3f3a20553..5e3e2e09c 100644 --- a/src/test/java/org/springframework/data/jpa/repository/CrudMethodMetadataUnitTests.java +++ b/src/test/java/org/springframework/data/jpa/repository/CrudMethodMetadataUnitTests.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"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ import org.springframework.data.jpa.repository.support.JpaEntityInformation; import org.springframework.data.jpa.repository.support.JpaRepositoryFactory; /** - * Integratio test for lock support. + * Integration test for lock support. * * @author Oliver Gierke * @author Thomas Darimont diff --git a/src/test/java/org/springframework/data/jpa/repository/sample/EmployeeRepositoryWithEmbeddedId.java b/src/test/java/org/springframework/data/jpa/repository/sample/EmployeeRepositoryWithEmbeddedId.java index dbfd9c5b4..edf15484f 100644 --- a/src/test/java/org/springframework/data/jpa/repository/sample/EmployeeRepositoryWithEmbeddedId.java +++ b/src/test/java/org/springframework/data/jpa/repository/sample/EmployeeRepositoryWithEmbeddedId.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2014 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. @@ -23,8 +23,8 @@ import org.springframework.data.jpa.domain.sample.EmbeddedIdExampleEmployeePK; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.querydsl.QueryDslPredicateExecutor; -import com.mysema.query.types.OrderSpecifier; -import com.mysema.query.types.Predicate; +import com.querydsl.core.types.OrderSpecifier; +import com.querydsl.core.types.Predicate; /** * Demonstrates the support for composite primary keys with {@code @EmbeddedId}. @@ -32,10 +32,9 @@ import com.mysema.query.types.Predicate; * @author Thomas Darimont */ @Lazy -public interface EmployeeRepositoryWithEmbeddedId extends - JpaRepository, +public interface EmployeeRepositoryWithEmbeddedId + extends JpaRepository, QueryDslPredicateExecutor { List findAll(Predicate predicate, OrderSpecifier... orders); - } diff --git a/src/test/java/org/springframework/data/jpa/repository/sample/EmployeeRepositoryWithIdClass.java b/src/test/java/org/springframework/data/jpa/repository/sample/EmployeeRepositoryWithIdClass.java index 17828740d..f5439053e 100644 --- a/src/test/java/org/springframework/data/jpa/repository/sample/EmployeeRepositoryWithIdClass.java +++ b/src/test/java/org/springframework/data/jpa/repository/sample/EmployeeRepositoryWithIdClass.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2014 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. @@ -23,8 +23,8 @@ import org.springframework.data.jpa.domain.sample.IdClassExampleEmployeePK; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.querydsl.QueryDslPredicateExecutor; -import com.mysema.query.types.OrderSpecifier; -import com.mysema.query.types.Predicate; +import com.querydsl.core.types.OrderSpecifier; +import com.querydsl.core.types.Predicate; /** * Demonstrates the support for composite primary keys with {@code @IdClass}. @@ -36,5 +36,4 @@ public interface EmployeeRepositoryWithIdClass extends JpaRepository { List findAll(Predicate predicate, OrderSpecifier... orders); - } diff --git a/src/test/java/org/springframework/data/jpa/repository/sample/MailMessageRepository.java b/src/test/java/org/springframework/data/jpa/repository/sample/MailMessageRepository.java index d2885db0b..3fdbd029b 100644 --- a/src/test/java/org/springframework/data/jpa/repository/sample/MailMessageRepository.java +++ b/src/test/java/org/springframework/data/jpa/repository/sample/MailMessageRepository.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. @@ -21,13 +21,14 @@ import org.springframework.data.jpa.domain.sample.MailMessage; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.querydsl.QueryDslPredicateExecutor; -import com.mysema.query.types.OrderSpecifier; -import com.mysema.query.types.Predicate; +import com.querydsl.core.types.OrderSpecifier; +import com.querydsl.core.types.Predicate; /** * @author Thomas Darimont */ -public interface MailMessageRepository extends JpaRepository, QueryDslPredicateExecutor { +public interface MailMessageRepository + extends JpaRepository, QueryDslPredicateExecutor { List findAll(Predicate predicate, OrderSpecifier... orders); } diff --git a/src/test/java/org/springframework/data/jpa/repository/sample/RoleRepository.java b/src/test/java/org/springframework/data/jpa/repository/sample/RoleRepository.java index 976810bc6..94954e15d 100644 --- a/src/test/java/org/springframework/data/jpa/repository/sample/RoleRepository.java +++ b/src/test/java/org/springframework/data/jpa/repository/sample/RoleRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2014 the original author or authors. + * Copyright 2008-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. @@ -24,7 +24,7 @@ import org.springframework.data.jpa.repository.QueryHints; import org.springframework.data.querydsl.QueryDslPredicateExecutor; import org.springframework.data.repository.CrudRepository; -import com.mysema.query.types.Predicate; +import com.querydsl.core.types.Predicate; /** * Typing interface for {@code Role}. diff --git a/src/test/java/org/springframework/data/jpa/repository/support/QueryDslJpaRepositoryTests.java b/src/test/java/org/springframework/data/jpa/repository/support/QueryDslJpaRepositoryTests.java index 7e32479da..4c8fd455d 100644 --- a/src/test/java/org/springframework/data/jpa/repository/support/QueryDslJpaRepositoryTests.java +++ b/src/test/java/org/springframework/data/jpa/repository/support/QueryDslJpaRepositoryTests.java @@ -43,10 +43,10 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.transaction.annotation.Transactional; -import com.mysema.query.types.Predicate; -import com.mysema.query.types.expr.BooleanExpression; -import com.mysema.query.types.path.PathBuilder; -import com.mysema.query.types.path.PathBuilderFactory; +import com.querydsl.core.types.Predicate; +import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.core.types.dsl.PathBuilder; +import com.querydsl.core.types.dsl.PathBuilderFactory; /** * Integration test for {@link QueryDslJpaRepository}. @@ -151,8 +151,8 @@ public class QueryDslJpaRepositoryTests { QUser user = QUser.user; - Page page = repository.findAll(user.firstname.isNotNull(), new PageRequest(0, 10, new Sort( - Sort.Direction.ASC, "colleagues.firstname"))); + Page page = repository.findAll(user.firstname.isNotNull(), + new PageRequest(0, 10, new Sort(Sort.Direction.ASC, "colleagues.firstname"))); assertThat(page.getContent(), hasSize(3)); assertThat(page.getContent(), hasItems(oliver, dave, carter)); @@ -169,8 +169,8 @@ public class QueryDslJpaRepositoryTests { QUser user = QUser.user; - Page page = repository.findAll(user.firstname.isNotNull(), new PageRequest(0, 10, new Sort( - Sort.Direction.ASC, "manager.firstname"))); + Page page = repository.findAll(user.firstname.isNotNull(), + new PageRequest(0, 10, new Sort(Sort.Direction.ASC, "manager.firstname"))); assertThat(page.getContent(), hasSize(3)); assertThat(page.getContent(), hasItems(dave, oliver, carter)); @@ -184,8 +184,8 @@ public class QueryDslJpaRepositoryTests { QUser user = QUser.user; - Page page = repository.findAll(user.firstname.isNotNull(), new PageRequest(0, 10, new Sort( - Sort.Direction.ASC, "firstname"))); + Page page = repository.findAll(user.firstname.isNotNull(), + new PageRequest(0, 10, new Sort(Sort.Direction.ASC, "firstname"))); assertThat(page.getContent(), hasSize(3)); assertThat(page.getContent(), hasItems(carter, dave, oliver)); @@ -199,8 +199,8 @@ public class QueryDslJpaRepositoryTests { QUser user = QUser.user; - Page page = repository.findAll(user.firstname.isNotNull(), new PageRequest(0, 10, new Sort(new Order( - Sort.Direction.ASC, "firstname").ignoreCase()))); + Page page = repository.findAll(user.firstname.isNotNull(), + new PageRequest(0, 10, new Sort(new Order(Sort.Direction.ASC, "firstname").ignoreCase()))); assertThat(page.getContent(), hasSize(3)); assertThat(page.getContent(), hasItems(carter, dave, oliver)); @@ -216,8 +216,8 @@ public class QueryDslJpaRepositoryTests { QUser user = QUser.user; - Page page = repository.findAll(user.firstname.isNotNull(), new PageRequest(0, 10, new Sort( - Sort.Direction.ASC, "address.streetName"))); + Page page = repository.findAll(user.firstname.isNotNull(), + new PageRequest(0, 10, new Sort(Sort.Direction.ASC, "address.streetName"))); assertThat(page.getContent(), hasSize(3)); assertThat(page.getContent(), hasItems(dave, carter, oliver)); diff --git a/src/test/java/org/springframework/data/jpa/repository/support/QueryDslRepositorySupportTests.java b/src/test/java/org/springframework/data/jpa/repository/support/QueryDslRepositorySupportTests.java index 4f6930299..fb35be54f 100644 --- a/src/test/java/org/springframework/data/jpa/repository/support/QueryDslRepositorySupportTests.java +++ b/src/test/java/org/springframework/data/jpa/repository/support/QueryDslRepositorySupportTests.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"); * you may not use this file except in compliance with the License. @@ -138,17 +138,14 @@ public class QueryDslRepositorySupportTests { } public List findUsersByLastname(String lastname) { - - return from(user).where(user.lastname.eq(lastname)).list(user); + return from(user).where(user.lastname.eq(lastname)).fetch(); } public long updateLastnamesTo(String lastname) { - return update(user).set(user.lastname, lastname).execute(); } public long deleteAllWithLastname(String lastname) { - return delete(user).where(user.lastname.eq(lastname)).execute(); } } diff --git a/src/test/java/org/springframework/data/jpa/repository/support/QuerydslIntegrationTests.java b/src/test/java/org/springframework/data/jpa/repository/support/QuerydslIntegrationTests.java index e3f0d12ea..9f69d5a9d 100644 --- a/src/test/java/org/springframework/data/jpa/repository/support/QuerydslIntegrationTests.java +++ b/src/test/java/org/springframework/data/jpa/repository/support/QuerydslIntegrationTests.java @@ -30,8 +30,8 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.transaction.annotation.Transactional; -import com.mysema.query.jpa.JPQLQuery; -import com.mysema.query.types.path.PathBuilder; +import com.querydsl.core.types.dsl.PathBuilder; +import com.querydsl.jpa.JPQLQuery; /** * Integration tests for {@link Querydsl}. @@ -47,14 +47,14 @@ public class QuerydslIntegrationTests { Querydsl querydsl; PathBuilder userPath; - JPQLQuery userQuery; + JPQLQuery userQuery; @Before public void setup() { userPath = new PathBuilder(User.class, "user"); querydsl = new Querydsl(em, userPath); - userQuery = querydsl.createQuery().from(userPath); + userQuery = querydsl.createQuery().select(userPath); } /** @@ -63,7 +63,7 @@ public class QuerydslIntegrationTests { @Test public void defaultOrderingShouldNotGenerateAnNullOrderingHint() { - JPQLQuery result = querydsl.applySorting(new Sort(new Sort.Order("firstname")), userQuery); + JPQLQuery result = querydsl.applySorting(new Sort(new Sort.Order("firstname")), userQuery); assertThat(result, is(notNullValue())); assertThat(result.toString(), is(not(anyOf(containsString("nulls first"), containsString("nulls last"))))); diff --git a/template.mf b/template.mf index d7fa9eb82..8f70460a6 100644 --- a/template.mf +++ b/template.mf @@ -7,7 +7,7 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5 Export-Template: org.springframework.data.jpa.*;version="${project.version}" Import-Template: - com.mysema.query.*;version="${querydsl:[=.=.=,+1.0.0)}";resolution:=optional, + com.querydsl.*;version="${querydsl:[=.=.=,+1.0.0)}";resolution:=optional, javax.persistence.*;version="${jpa:[=.=.=,+1.0.0)}", javax.annotation.*;version="0.0.0", javax.enterprise.*;version="${cdi:[=.=.=,+1.0.0)}";resolution:=optional,