DATAJPA-1140 - Added test for reproducing the issue.
Tests added to reproduce failure of parameter binding when a mixture of SpEL expressions and normal parameters is used. Original pull request: #205, #206.
This commit is contained in:
committed by
Oliver Gierke
parent
f1f5ca98c1
commit
37aabff481
@@ -88,6 +88,7 @@ import com.google.common.base.Optional;
|
||||
* @author Thomas Darimont
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
* @author Kevin Peters
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("classpath:application-context.xml")
|
||||
@@ -1540,6 +1541,47 @@ public class UserRepositoryTests {
|
||||
|
||||
assertThat(users.getContent()).hasSize(2).containsExactly(thirdUser, fourthUser);
|
||||
}
|
||||
|
||||
@Test // DATAJPA-1140
|
||||
public void shouldFindUsersByUserFirstnameAsSpELExpressionAndLastnameAsStringInStringBasedQuery() {
|
||||
|
||||
flushTestUsers();
|
||||
|
||||
List<User> users = repository.findUsersByUserFirstnameAsSpELExpressionAndLastnameAsString(firstUser, firstUser.getLastname());
|
||||
|
||||
assertThat(users).containsOnly(firstUser);
|
||||
}
|
||||
|
||||
@Test // DATAJPA-1140
|
||||
public void shouldFindUsersByFirstnameAsStringAndUserLastnameAsSpELExpressionInStringBasedQuery() {
|
||||
|
||||
flushTestUsers();
|
||||
|
||||
List<User> users = repository.findUsersByFirstnameAsStringAndUserLastnameAsSpELExpression(firstUser.getFirstname(), firstUser);
|
||||
|
||||
assertThat(users).containsOnly(firstUser);
|
||||
}
|
||||
|
||||
|
||||
@Test // DATAJPA-1140
|
||||
public void shouldFindUsersByUserFirstnameAsSpELExpressionAndLastnameAsFakeSpELExpressionInStringBasedQuery() {
|
||||
|
||||
flushTestUsers();
|
||||
|
||||
List<User> users = repository.findUsersByUserFirstnameAsSpELExpressionAndLastnameAsFakeSpELExpression(firstUser, firstUser.getLastname());
|
||||
|
||||
assertThat(users).containsOnly(firstUser);
|
||||
}
|
||||
|
||||
@Test // DATAJPA-1140
|
||||
public void shouldFindUsersByFirstnameAsFakeSpELExpressionAndUserLastnameAsSpELExpressionInStringBasedQuery() {
|
||||
|
||||
flushTestUsers();
|
||||
|
||||
List<User> users = repository.findUsersByFirstnameAsFakeSpELExpressionAndUserLastnameAsSpELExpression(firstUser.getFirstname(), firstUser);
|
||||
|
||||
assertThat(users).containsOnly(firstUser);
|
||||
}
|
||||
|
||||
@Test // DATAJPA-629
|
||||
public void shouldfindUsersBySpELExpressionParametersWithSpelTemplateExpression() {
|
||||
|
||||
@@ -48,6 +48,7 @@ import com.google.common.base.Optional;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
* @author Kevin Peters
|
||||
*/
|
||||
public interface UserRepository
|
||||
extends JpaRepository<User, Integer>, JpaSpecificationExecutor<User>, UserRepositoryCustom {
|
||||
@@ -429,6 +430,22 @@ public interface UserRepository
|
||||
value = "select * from (select rownum() as RN, u.* from SD_User u) where RN between ?#{ #pageable.offset -1} and ?#{#pageable.offset + #pageable.pageSize}",
|
||||
countQuery = "select count(u.id) from SD_User u", nativeQuery = true)
|
||||
Page<User> findUsersInNativeQueryWithPagination(Pageable pageable);
|
||||
|
||||
// DATAJPA-1140
|
||||
@Query("select u from User u where u.firstname =:#{#user.firstname} and u.lastname =:lastname")
|
||||
List<User> findUsersByUserFirstnameAsSpELExpressionAndLastnameAsString(@Param("user") User user, @Param("lastname") String lastname);
|
||||
|
||||
// DATAJPA-1140
|
||||
@Query("select u from User u where u.firstname =:firstname and u.lastname =:#{#user.lastname}")
|
||||
List<User> findUsersByFirstnameAsStringAndUserLastnameAsSpELExpression(@Param("firstname") String firstname, @Param("user") User user);
|
||||
|
||||
// DATAJPA-1140
|
||||
@Query("select u from User u where u.firstname =:#{#user.firstname} and u.lastname =:#{#lastname}")
|
||||
List<User> findUsersByUserFirstnameAsSpELExpressionAndLastnameAsFakeSpELExpression(@Param("user") User user, @Param("lastname") String lastname);
|
||||
|
||||
// DATAJPA-1140
|
||||
@Query("select u from User u where u.firstname =:#{#firstname} and u.lastname =:#{#user.lastname}")
|
||||
List<User> findUsersByFirstnameAsFakeSpELExpressionAndUserLastnameAsSpELExpression(@Param("firstname") String firstname, @Param("user") User user);
|
||||
|
||||
// DATAJPA-629
|
||||
@Query("select u from #{#entityName} u where u.firstname = ?#{[0]} and u.lastname = ?#{[1]}")
|
||||
|
||||
Reference in New Issue
Block a user