
bindings.bind(store.address.city).single((path, value)->path.endsWith(value));
bindings.bind(String.class).single((StringPathpath,Stringvalue)->path.contains(value));
--不綁定password字段,即password字段不作為查詢條件
bindings.excluding(root.password);
http://docs.spring.io/spring-data/jpa/docs/current/reference/html/#core.web.type-safe
--頁面?zhèn)鬟fdateOfBirth數(shù)組,包括mininum,maxinum。注意:對(duì)于mongo,between $min and $max,因此頁面?zhèn)鬟f參數(shù)時(shí),第一個(gè)element為小值,第二個(gè)為大值。
bindings.bind(user.dateOfBirth).all((path,value)->{
? ? ? Iterator?it=value.iterator();
? ? ? return path.between(it.next(),it.next());//--需要進(jìn)行Object cast到path指定類型
}
);
org.springframework.data.querydsl.binding.QuerydslBindings判斷一個(gè)屬性是否pathVisible規(guī)則:
this.aliases.contains(path) &&?
!this.blackList.contains(path)?true:(this.whiteList.isEmpty()?(this.excludeUnlistedProperties?false:!this.blackList.contains(path)):this.whiteList.contains(path));
針對(duì)關(guān)系型數(shù)據(jù)庫,使用ElementCollection表示Map類型字段。
@Entity
public class Product extends AbstractEntity {
@ElementCollection
private Map<String, String> attributes = new HashMap(); }
Order的構(gòu)造函數(shù)使用了對(duì)象copy,這樣做避免Customer在修改了Address后,Order中的地址不會(huì)變化。
public Order(Customer customer, Address shippingAddress, Address billingAddress) {
Assert.notNull(customer);
Assert.notNull(shippingAddress);
this.customer = customer;
this.shippingAddress = shippingAddress.getCopy();
this.billingAddress = billingAddress == null ? null : billingAddress.getCopy();
}