diff --git a/pom.xml b/pom.xml
index cd5ec9e53..fc0015b39 100644
--- a/pom.xml
+++ b/pom.xml
@@ -60,7 +60,7 @@
2.1.1
2.3.2
1.6.12
- 2.3.0
+ 2.3.3
4.8.1
2.0.0
1.6.1
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 0fee84bdb..2eeeeba92 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
@@ -30,7 +30,6 @@ 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.Expression;
import com.mysema.query.types.OrderSpecifier;
@@ -51,6 +50,7 @@ public class QueryDslJpaRepository extends SimpleJpa
private final EntityManager em;
private final EntityPath path;
private final PathBuilder builder;
+ private final PersistenceProvider provider;
/**
* Creates a new {@link QueryDslJpaRepository} from the given domain class and {@link EntityManager}. This will use
@@ -79,6 +79,7 @@ public class QueryDslJpaRepository extends SimpleJpa
this.em = entityManager;
this.path = resolver.createPath(entityMetadata.getJavaType());
this.builder = new PathBuilder(path.getType(), path.getMetadata());
+ this.provider = PersistenceProvider.fromEntityManager(entityManager);
}
/*
@@ -148,8 +149,7 @@ public class QueryDslJpaRepository extends SimpleJpa
* @return
*/
protected JPQLQuery createQuery(Predicate... predicate) {
-
- return new JPAQuery(em).from(path).where(predicate);
+ return QuerydslUtils.createQueryInstance(em, provider).from(path).where(predicate);
}
/**
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 8d461b6bb..6b744fcd1 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
@@ -26,7 +26,6 @@ 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.JPAQuery;
import com.mysema.query.jpa.impl.JPAUpdateClause;
import com.mysema.query.types.EntityPath;
import com.mysema.query.types.path.PathBuilder;
@@ -40,8 +39,9 @@ import com.mysema.query.types.path.PathBuilderFactory;
@Repository
public abstract class QueryDslRepositorySupport {
- private EntityManager entityManager;
private PathBuilderFactory builderFactory = new PathBuilderFactory();
+ private EntityManager entityManager;
+ private PersistenceProvider provider;
/**
* Setter to inject {@link EntityManager}.
@@ -53,6 +53,7 @@ public abstract class QueryDslRepositorySupport {
Assert.notNull(entityManager);
this.entityManager = entityManager;
+ this.provider = PersistenceProvider.fromEntityManager(entityManager);
}
/**
@@ -78,8 +79,7 @@ public abstract class QueryDslRepositorySupport {
* @return
*/
protected JPQLQuery from(EntityPath>... paths) {
-
- return new JPAQuery(entityManager).from(paths);
+ return QuerydslUtils.createQueryInstance(entityManager, provider).from(paths);
}
/**
diff --git a/src/main/java/org/springframework/data/jpa/repository/support/QuerydslUtils.java b/src/main/java/org/springframework/data/jpa/repository/support/QuerydslUtils.java
new file mode 100644
index 000000000..efbf8bc5c
--- /dev/null
+++ b/src/main/java/org/springframework/data/jpa/repository/support/QuerydslUtils.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2012 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.data.jpa.repository.support;
+
+import javax.persistence.EntityManager;
+
+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.JPAQuery;
+
+/**
+ * Utility methods for Querydsl.
+ *
+ * @author Oliver Gierke
+ */
+class QuerydslUtils {
+
+ /**
+ * Creates the {@link JPQLQuery} instance based on the given {@link EntityManager} and {@link PersistenceProvider}.
+ *
+ * @return
+ */
+ public static JPQLQuery createQueryInstance(EntityManager em, PersistenceProvider provider) {
+
+ switch (provider) {
+ case ECLIPSELINK:
+ return new JPAQuery(em, EclipseLinkTemplates.DEFAULT);
+ case HIBERNATE:
+ return new JPAQuery(em, HQLTemplates.DEFAULT);
+ case OPEN_JPA:
+ return new JPAQuery(em, OpenJPATemplates.DEFAULT);
+ case GENERIC_JPA:
+ default:
+ return new JPAQuery(em);
+ }
+ }
+}