diff --git a/pom.xml b/pom.xml
index 7f2adf4e6b..a14b995e41 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.springframework.dataspring-data-jpa
- 1.5.0.BUILD-SNAPSHOT
+ 1.5.0.DATAJPA-307-SNAPSHOTSpring Data JPASpring Data module for JPA repositories.
@@ -23,14 +23,13 @@
DATAJPA2.4.0
- 3.6.10.Final
- 1.8.0.10
+ 4.1.10.Final2.0.02.2.1
- 1.7.0.BUILD-SNAPSHOT
+ 1.7.0.DATACMNS-293-SNAPSHOT
-
+
hibernate-41
@@ -128,6 +127,14 @@
test
+
+
+ com.h2database
+ h2
+ 1.3.172
+ test
+
+
joda-timejoda-time
@@ -161,18 +168,6 @@
openjpa-persistence-jdbc${openjpa}true
-
-
- commons-logging
- commons-logging
-
-
-
-
- junit
- junit
-
-
@@ -241,12 +236,6 @@
${openjpa}runtime
-
- org.hsqldb
- hsqldb
- ${hsqldb1}
- runtime
-
@@ -318,12 +307,6 @@
**/OpenJpa*Tests.java-javaagent:${settings.localRepository}/org/apache/openjpa/openjpa/${openjpa}/openjpa-${openjpa}.jar
-
- org.hsqldb:hsqldb
-
-
- ${settings.localRepository}/org/hsqldb/hsqldb/${hsqldb1}/hsqldb-${hsqldb1}.jar
-
@@ -417,7 +400,7 @@
spring-libs-snapshot
- http://repo.springsource.org/libs-snapshot-local
+ http://repo.springsource.org/libs-snapshot
diff --git a/src/main/java/org/springframework/data/jpa/repository/augment/AbstractJpaAnnotationBasedQueryAugmentor.java b/src/main/java/org/springframework/data/jpa/repository/augment/AbstractJpaAnnotationBasedQueryAugmentor.java
new file mode 100644
index 0000000000..799a084db4
--- /dev/null
+++ b/src/main/java/org/springframework/data/jpa/repository/augment/AbstractJpaAnnotationBasedQueryAugmentor.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2013 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.augment;
+
+import java.lang.annotation.Annotation;
+
+import org.springframework.data.jpa.repository.support.JpaCriteriaQueryContext;
+import org.springframework.data.jpa.repository.support.JpaQueryContext;
+import org.springframework.data.jpa.repository.support.JpaUpdateContext;
+import org.springframework.data.repository.augment.AnnotationBasedQueryAugmentor;
+
+/**
+ * @author Oliver Gierke
+ */
+public abstract class AbstractJpaAnnotationBasedQueryAugmentor extends
+ AnnotationBasedQueryAugmentor, JpaQueryContext, JpaUpdateContext>> {
+
+}
diff --git a/src/main/java/org/springframework/data/jpa/repository/augment/JpaSoftDeleteQueryAugmentor.java b/src/main/java/org/springframework/data/jpa/repository/augment/JpaSoftDeleteQueryAugmentor.java
new file mode 100644
index 0000000000..e8b0521e9e
--- /dev/null
+++ b/src/main/java/org/springframework/data/jpa/repository/augment/JpaSoftDeleteQueryAugmentor.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2013 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.augment;
+
+
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+
+import org.springframework.beans.BeanWrapper;
+import org.springframework.data.jpa.repository.support.JpaCriteriaQueryContext;
+import org.springframework.data.jpa.repository.support.JpaQueryContext;
+import org.springframework.data.jpa.repository.support.JpaUpdateContext;
+import org.springframework.data.repository.SoftDelete;
+import org.springframework.data.repository.augment.AbstractSoftDeleteQueryAugmentor;
+import org.springframework.data.repository.augment.QueryContext.QueryMode;
+
+/**
+ * JPA implementation of {@link AbstractSoftDeleteQueryAugmentor} to transparently turn delete calls into entity
+ * updates. Also filters queries accordingly.
+ *
+ * @author Oliver Gierke
+ */
+public class JpaSoftDeleteQueryAugmentor extends
+ AbstractSoftDeleteQueryAugmentor, JpaQueryContext, JpaUpdateContext>> {
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.data.repository.augment.AnnotationBasedQueryAugmentor#prepareNativeQuery(org.springframework.data.repository.augment.QueryContext, java.lang.annotation.Annotation)
+ */
+ @Override
+ protected JpaQueryContext prepareNativeQuery(JpaQueryContext context, SoftDelete expression) {
+
+ if (!context.getMode().in(QueryMode.FIND)) {
+ return context;
+ }
+
+ String string = context.getQueryString();
+ // TODO: Augment query;
+
+ return context.withQuery(string);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.data.jpa.repository.sample.JpaSoftDeleteQueryAugmentor#prepareQuery(org.springframework.data.jpa.repository.support.JpaCriteriaQueryContext, org.springframework.data.jpa.repository.support.GlobalFilter)
+ */
+ @Override
+ protected JpaCriteriaQueryContext, ?> prepareQuery(JpaCriteriaQueryContext, ?> context, SoftDelete expression) {
+
+ CriteriaQuery> criteriaQuery = context.getQuery();
+ CriteriaBuilder builder = context.getCriteriaBuilder();
+
+ Predicate predicate = builder.equal(context.getRoot().get(expression.value()), expression.flagMode().activeValue());
+ Predicate restriction = criteriaQuery.getRestriction();
+
+ criteriaQuery.where(restriction == null ? predicate : builder.and(restriction, predicate));
+
+ return context;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.data.repository.augment.AbstractSoftDeleteQueryAugmentor#updateDeletedState(java.lang.Object)
+ */
+ @Override
+ public void updateDeletedState(Object entity, JpaUpdateContext> context) {
+ context.getEntityManager().merge(entity);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.data.repository.augment.AbstractSoftDeleteQueryAugmentor#prepareBeanWrapper(org.springframework.data.repository.augment.UpdateContext)
+ */
+ @Override
+ protected BeanWrapper createBeanWrapper(JpaUpdateContext> context) {
+ return new PropertyChangeEnsuringBeanWrapper(context.getEntity());
+ }
+}
diff --git a/src/main/java/org/springframework/data/jpa/repository/augment/LockModeQueryAugmentor.java b/src/main/java/org/springframework/data/jpa/repository/augment/LockModeQueryAugmentor.java
new file mode 100644
index 0000000000..74a7dac145
--- /dev/null
+++ b/src/main/java/org/springframework/data/jpa/repository/augment/LockModeQueryAugmentor.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2013 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.augment;
+
+import javax.persistence.Query;
+
+import org.springframework.data.jpa.repository.Lock;
+import org.springframework.data.jpa.repository.support.JpaQueryContext;
+
+/**
+ * @author Oliver Gierke
+ */
+public class LockModeQueryAugmentor extends AbstractJpaAnnotationBasedQueryAugmentor {
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.data.repository.augment.AnnotationBasedQueryAugmentor#prepareNativeQuery(org.springframework.data.repository.augment.QueryContext, java.lang.annotation.Annotation)
+ */
+ @Override
+ protected JpaQueryContext prepareNativeQuery(JpaQueryContext context, Lock expression) {
+
+ Query query = context.getQuery();
+ query.setLockMode(expression.value());
+
+ return context;
+ }
+}
diff --git a/src/main/java/org/springframework/data/jpa/repository/augment/PropertyChangeEnsuringBeanWrapper.java b/src/main/java/org/springframework/data/jpa/repository/augment/PropertyChangeEnsuringBeanWrapper.java
new file mode 100644
index 0000000000..8f14f93cc1
--- /dev/null
+++ b/src/main/java/org/springframework/data/jpa/repository/augment/PropertyChangeEnsuringBeanWrapper.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2011 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.augment;
+
+import java.lang.reflect.Method;
+
+import org.springframework.data.support.DirectFieldAccessFallbackBeanWrapper;
+import org.springframework.util.ReflectionUtils;
+
+/**
+ * Custom {@link DirectFieldAccessFallbackBeanWrapper} to hook in additional functionality when setting a property by
+ * field access.
+ *
+ * @author Oliver Gierke
+ */
+class PropertyChangeEnsuringBeanWrapper extends DirectFieldAccessFallbackBeanWrapper {
+
+ public PropertyChangeEnsuringBeanWrapper(Object entity) {
+ super(entity);
+ }
+
+ /**
+ * We in case of setting the value using field access, we need to make sure that EclipseLink detects the change.
+ * Hence we check for an EclipseLink specific generated method that is used to record the changes and invoke it if
+ * available.
+ *
+ * @see org.springframework.data.support.DirectFieldAccessFallbackBeanWrapper#setPropertyUsingFieldAccess(java.lang.String,
+ * java.lang.Object)
+ */
+ @Override
+ protected void setPropertyUsingFieldAccess(String propertyName, Object value) {
+
+ Object oldValue = getPropertyValue(propertyName);
+ super.setPropertyUsingFieldAccess(propertyName, oldValue);
+ triggerPropertyChangeMethodIfAvailable(propertyName, oldValue, oldValue);
+ }
+
+ private void triggerPropertyChangeMethodIfAvailable(String propertyName, Object oldValue, Object value) {
+
+ Method method = ReflectionUtils.findMethod(getWrappedClass(), "_persistence_propertyChange", String.class,
+ Object.class, Object.class);
+
+ if (method == null) {
+ return;
+ }
+
+ ReflectionUtils.invokeMethod(method, getWrappedInstance(), propertyName, oldValue, value);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/springframework/data/jpa/repository/augment/QueryDslSoftDeleteQueryAugmentor.java b/src/main/java/org/springframework/data/jpa/repository/augment/QueryDslSoftDeleteQueryAugmentor.java
new file mode 100644
index 0000000000..be74a91da1
--- /dev/null
+++ b/src/main/java/org/springframework/data/jpa/repository/augment/QueryDslSoftDeleteQueryAugmentor.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2011 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.augment;
+
+import org.springframework.beans.BeanWrapper;
+import org.springframework.data.jpa.repository.support.QueryDslJpaQueryContext;
+import org.springframework.data.jpa.repository.support.QueryDslJpaUpdateContext;
+import org.springframework.data.jpa.repository.support.QueryDslQueryContext;
+import org.springframework.data.repository.SoftDelete;
+import org.springframework.data.repository.augment.AbstractSoftDeleteQueryAugmentor;
+import org.springframework.data.repository.augment.QueryContext.QueryMode;
+
+import com.mysema.query.jpa.JPQLQuery;
+import com.mysema.query.types.Predicate;
+import com.mysema.query.types.path.PathBuilder;
+
+/**
+ * QueryDsl implementation of {@link AbstractSoftDeleteQueryAugmentor} to transparently turn delete calls into entity
+ * updates and filter queries accordingly.
+ *
+ * @author Dev Naruka
+ *
+ */
+public class QueryDslSoftDeleteQueryAugmentor extends
+ AbstractSoftDeleteQueryAugmentor, QueryDslQueryContext, QueryDslJpaUpdateContext>> {
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.data.repository.augment.AnnotationBasedQueryAugmentor#prepareNativeQuery(org.springframework.data.repository.augment.QueryContext, java.lang.annotation.Annotation)
+ */
+ @Override
+ protected QueryDslQueryContext prepareNativeQuery(
+ QueryDslQueryContext context, SoftDelete expression) {
+ if (!context.getMode().in(QueryMode.FIND)) {
+ return context;
+ }
+
+ String string = context.getQueryString();
+ // TODO: Augment query;
+
+ return context.withQuery(string);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.data.repository.augment.AnnotationBasedQueryAugmentor#prepareQuery(org.springframework.data.repository.augment.QueryContext, java.lang.annotation.Annotation)
+ */
+ @Override
+ protected QueryDslJpaQueryContext> prepareQuery(
+ QueryDslJpaQueryContext> context, SoftDelete expression) {
+ JPQLQuery query = context.getQuery();
+ PathBuilder> builder = context.getPathBuilder();
+
+ Predicate predicate = builder.get(expression.value()).eq(expression.flagMode().activeValue());
+
+ query.where(predicate);
+
+ return context;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.data.repository.augment.AbstractSoftDeleteQueryAugmentor#updateDeletedState(java.lang.Object, org.springframework.data.repository.augment.UpdateContext)
+ */
+ @Override
+ public void updateDeletedState(Object entity,
+ QueryDslJpaUpdateContext> context) {
+
+ @SuppressWarnings("unchecked")
+ QueryDslJpaUpdateContext