DATAJPA-506 - Re-enabled query method invocation with wrapper type results.
The custom handling for Blobs applies to strict conversion as it uses the simple method return type to decide whether to trigger a conversion. It now rather uses the returned domain type which automatically unwraps wrapper types like Guava's Optional. Applied some polishing to the ConversionService setup in JpaQueryExecution to make more obvious that it's only mean to execute very specific conversions. Added Guava as test dependency and explicit dependency for the Mysema APT plugin as the test scope only would make it invisible for the plugin.
This commit is contained in:
@@ -63,6 +63,8 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
/**
|
||||
* Base integration test class for {@code UserRepository}. Loads a basic (non-namespace) Spring configuration file as
|
||||
* well as Hibernate configuration to execute tests.
|
||||
@@ -1573,6 +1575,20 @@ public class UserRepositoryTests {
|
||||
assertThat(secondPage.getContent(), hasItems(youngest3));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAJPA-506
|
||||
*/
|
||||
@Test
|
||||
public void invokesQueryWithWrapperType() {
|
||||
|
||||
flushTestUsers();
|
||||
|
||||
Optional<User> result = repository.findOptionalByEmailAddress("gierke@synyx.de");
|
||||
|
||||
assertThat(result.isPresent(), is(true));
|
||||
assertThat(result.get(), is(firstUser));
|
||||
}
|
||||
|
||||
private Page<User> executeSpecWithSort(Sort sort) {
|
||||
|
||||
flushTestUsers();
|
||||
|
||||
@@ -39,6 +39,8 @@ import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
/**
|
||||
* Repository interface for {@code User}s.
|
||||
*
|
||||
@@ -445,10 +447,16 @@ public interface UserRepository extends JpaRepository<User, Integer>, JpaSpecifi
|
||||
* @see DATAJPA-551
|
||||
*/
|
||||
Slice<User> findTop2UsersBy(Pageable page);
|
||||
|
||||
|
||||
/**
|
||||
* @see DATAJPA-506
|
||||
*/
|
||||
@Query(value = "select u.binaryData from User u where u.id = ?", nativeQuery = true)
|
||||
@Query(value = "select u.binaryData from User u where u.id = ?1", nativeQuery = true)
|
||||
byte[] findBinaryDataByIdNative(Integer id);
|
||||
|
||||
/**
|
||||
* @see DATAJPA-506
|
||||
*/
|
||||
@Query("select u from User u where u.emailAddress = ?1")
|
||||
Optional<User> findOptionalByEmailAddress(String emailAddress);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user