DATACMNS-669 - Polishing.
QuerydslBindings now uses a builder style pattern to define custom bindings. This allows to define the same binding for multiple properties of the same type in one configuration call. Introduced MultiValueBinding to be able to register a binding for multiple source values (i.e. if multiple values are provided for the same parameter). The previously named QuerydslBinding is now a SingleValueBinding which gets adapted to by extracting the first element of the values provided considered as collection. Slightly refined the generics signature in QuerydslBinding for better type derivation in Lambdas. Removed the need for QuerydslBindingContext by moving a few properties around. The ConversionService instance is now piped into the QuerydslPredicateBuilder directly. Added a bit of sample data to the Users test domain type to be able to execute the generated Predicates in tests to validate their correctness. Original pull request: #132.
This commit is contained in:
@@ -22,6 +22,11 @@ import com.mysema.query.annotations.QueryEntity;
|
||||
*/
|
||||
@QueryEntity
|
||||
public class Address {
|
||||
String street;
|
||||
String city;
|
||||
|
||||
public String street, city;
|
||||
|
||||
public Address(String street, String city) {
|
||||
this.street = street;
|
||||
this.city = city;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,16 @@ import com.mysema.query.annotations.QueryEntity;
|
||||
@QueryEntity
|
||||
public class User {
|
||||
|
||||
String firstname;
|
||||
String lastname;
|
||||
Date dateOfBirth;
|
||||
public String firstname, lastname;
|
||||
public Date dateOfBirth;
|
||||
public Address address;
|
||||
public List<String> nickNames;
|
||||
public Long inceptionYear;
|
||||
|
||||
Address address;
|
||||
List<String> nickNames;
|
||||
Long inceptionYear;
|
||||
public User(String firstname, String lastname, Address address) {
|
||||
|
||||
this.firstname = firstname;
|
||||
this.lastname = lastname;
|
||||
this.address = address;
|
||||
}
|
||||
}
|
||||
|
||||
37
src/test/java/org/springframework/data/querydsl/Users.java
Normal file
37
src/test/java/org/springframework/data/querydsl/Users.java
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.querydsl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class Users {
|
||||
|
||||
public static final User OLIVER, CHRISTOPH;
|
||||
|
||||
public static final List<User> USERS;
|
||||
|
||||
static {
|
||||
|
||||
OLIVER = new User("Oliver", "Gierke", new Address("Somewhere", "Dresden"));
|
||||
CHRISTOPH = new User("Christoph", "Strobl", new Address("Somewhere", "Linz"));
|
||||
|
||||
USERS = Arrays.asList(OLIVER, CHRISTOPH);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user