DATAJPA-373 - Fixed potential NullPointerException in StringQuery.

This commit is contained in:
Oliver Gierke
2013-07-24 09:56:22 +02:00
parent 3fd4fd1abe
commit 295424feb2
2 changed files with 10 additions and 2 deletions

View File

@@ -272,8 +272,8 @@ class StringQuery {
* @param position
* @return
*/
public boolean hasPosition(int position) {
return this.name == null && this.position == position;
public boolean hasPosition(Integer position) {
return position != null && this.name == null && this.position == position;
}
/**

View File

@@ -90,6 +90,14 @@ public class StringQueryUnitTests {
assertThat(binding.getType(), is(Type.ENDING_WITH));
}
/**
* @see DATAJPA-373
*/
@Test
public void handlesMultipleNamedLikeBindingsCorrectly() {
new StringQuery("select u from User u where u.firstname like %:firstname or foo like :bar");
}
@Test(expected = IllegalArgumentException.class)
public void rejectsDifferentBindingsForRepeatedParameter() {
new StringQuery("select u from User u where u.firstname like %?1 and u.lastname like ?1%");