Skip to content

DATACMNS-1002 - Generic class parameter not being bound to query. #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* Class to abstract a single parameter of a query method. It is held in the context of a {@link Parameters} instance.
*
* @author Oliver Gierke
* @author Michael Bragg
*/
public class Parameter {

Expand Down Expand Up @@ -76,7 +77,7 @@ public boolean isSpecialParameter() {
* @return
*/
public boolean isBindable() {
return !isSpecialParameter();
return this.isExplicitlyNamed() || !isSpecialParameter();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* Unit test for {@link Parameters}.
*
* @author Oliver Gierke
* @author Michael Bragg
*/
public class ParametersUnitTests {

Expand Down Expand Up @@ -131,6 +132,16 @@ public void detectsExplicitlyNamedParameter() throws Exception {
assertThat(parameter.isExplicitlyNamed(), is(true));
}

@Test // DATACMNS-1002
public void detectsAndBindsDynamicProjectionParameter() throws Exception {

Parameter parameter = getParametersFor("validWithDynamicBind", Class.class).getBindableParameter(0);

assertThat(parameter.getName(), is(notNullValue()));
assertThat(parameter.isBindable(), is(true));
assertThat(parameter.isExplicitlyNamed(), is(true));
}

@Test // DATACMNS-731
public void doesNotConsiderParameterExplicitlyNamedEvenIfNamePresent() throws Exception {

Expand Down Expand Up @@ -193,6 +204,8 @@ static interface SampleDao {

<T> T dynamicBind(Class<T> type, Class<?> one, Class<Object> two);

<T> T validWithDynamicBind(@Param("type") Class<T> type);

void methodWithOptional(Optional<String> optional);
}
}