DATAJPA-460 - Reduce implementation to core requested feature.

Removed the additional deleted flag in @Query as we currently already ship with a method to manually implement delete-queries (using @Modifying and a manually defined JPQL query).

Tiny optimization in DeleteExecution.

Original pull request: #66.
This commit is contained in:
Oliver Gierke
2014-03-31 14:35:42 +02:00
parent 99ae3c4567
commit 3ff4f94c68
7 changed files with 9 additions and 95 deletions

View File

@@ -1298,7 +1298,6 @@ public class UserRepositoryTests {
assertThat(result, hasItems(firstUser, secondUser));
}
/**
* @see DATAJPA-460
*/
@@ -1357,42 +1356,6 @@ public class UserRepositoryTests {
assertThat(repository.deleteByLastname("dorfuaeB"), empty());
}
/**
* @see DATAJPA-460
*/
@Test
public void deleteByUsingAnnotatedQueryShouldReturnListOfDeletedElementsWhenRetunTypeIsCollectionLike() {
flushTestUsers();
List<User> result = repository.deleteByLastnameUsingAnnotatedQuery(firstUser.getLastname());
assertThat(result, hasItem(firstUser));
assertThat(result, hasSize(1));
}
/**
* @see DATAJPA-460
*/
@Test
public void deleteByUsingAnnotatedQueryShouldRemoveElementsMatchingDerivedQuery() {
flushTestUsers();
repository.removeByLastnameUsingAnnotatedQuery(firstUser.getLastname());
assertThat(repository.countByLastname(firstUser.getLastname()), is(0L));
}
/**
* @see DATAJPA-460
*/
@Test
public void deleteByUsingAnnotatedQueryShouldReturnNumberOfDocumentsRemovedIfReturnTypeIsLong() {
flushTestUsers();
assertThat(repository.removeByLastnameUsingAnnotatedQuery(firstUser.getLastname()), is(1L));
}
private Page<User> executeSpecWithSort(Sort sort) {
flushTestUsers();

View File

@@ -317,8 +317,8 @@ public interface UserRepository extends JpaRepository<User, Integer>, JpaSpecifi
* @see DATAJPA-496
*/
List<User> findByAttributesIn(Set<String> attributes);
/**
/**
* @see DATAJPA-460
*/
Long removeByLastname(String lastname);
@@ -327,16 +327,4 @@ public interface UserRepository extends JpaRepository<User, Integer>, JpaSpecifi
* @see DATAJPA-460
*/
List<User> deleteByLastname(String lastname);
/**
* @see DATAJPA-460
*/
@Query(value = "select u from User u where u.lastname = ?1", delete = true)
List<User> deleteByLastnameUsingAnnotatedQuery(String lastname);
/**
* @see DATAJPA-460
*/
@Query(value = "select u from User u where u.lastname = ?1", delete = true)
Long removeByLastnameUsingAnnotatedQuery(String lastname);
}