DATAJPA-505 - Projections for basic primitive arrays should use SingleEntityExecution.

We now execute a query as a SingleEntityExecution if the return-type of the particular query-method is an basic char[],Character[], byte[], Byte[].
Previously we tried to do an CollectionExecution which didn't return all elements of the actual result (e.g. the byte[]).

Although EclipseLink and Hibernate support the use of array elements in projections OpenJPA seems not to. Filed https://issues.apache.org/jira/browse/OPENJPA-2484 to track the issue. Since OpenJPA prevents the bootstrap of the whole test suite I had to comment the query method + tests out. Tested Hibernate / EclipseLink by temporarily excluding all OpenJPA tests from the test-suite.

Original pull request: #71.
This commit is contained in:
Thomas Darimont
2014-03-24 09:24:52 +01:00
committed by Oliver Gierke
parent 3ff4f94c68
commit 44d7e2ef24
3 changed files with 52 additions and 0 deletions

View File

@@ -1215,6 +1215,7 @@ public class UserRepositoryTests {
List<User> result = repository.findByBinaryData(data);
assertThat(result, hasSize(1));
assertThat(result, hasItem(firstUser));
assertThat(result.get(0).getBinaryData(), is(data));
}
/**
@@ -1356,6 +1357,24 @@ public class UserRepositoryTests {
assertThat(repository.deleteByLastname("dorfuaeB"), empty());
}
/**
* @see DATAJPA-505
* @see https://issues.apache.org/jira/browse/OPENJPA-2484
*/
@Test
@Ignore
public void findBinaryDataByIdJpaQl() throws Exception {
byte[] data = "Woho!!".getBytes("UTF-8");
firstUser.setBinaryData(data);
flushTestUsers();
byte[] result = null; // repository.findBinaryDataByIdJpaQl(firstUser.getId());
assertThat(result.length, is(data.length));
assertThat(result, is(data));
}
private Page<User> executeSpecWithSort(Sort sort) {
flushTestUsers();

View File

@@ -327,4 +327,11 @@ public interface UserRepository extends JpaRepository<User, Integer>, JpaSpecifi
* @see DATAJPA-460
*/
List<User> deleteByLastname(String lastname);
/**
* @see DATAJPA-505
* @see https://issues.apache.org/jira/browse/OPENJPA-2484
*/
// @Query(value = "select u.binaryData from User u where u.id = :id")
// byte[] findBinaryDataByIdJpaQl(@Param("id") Integer id);
}