下面是一個場景片斷,模糊查找數據庫中用戶帳號為'test',郵件地址為'georgehill@21cn.com'的實例,忽略大小寫。




















示例查詢需要生成Example實例,可以通過Example的靜態方法create生成。Example類有下面的幾個方法指定查詢的方式:
excludeZeroes
public Example excludeZeroes()
- Exclude zero-valued properties
excludeNone
public Example excludeNone()
- Don't exclude null or zero-valued properties
enableLike
public Example enableLike(MatchMode matchMode)
- Use the "like" operator for all string-valued properties
enableLike
public Example enableLike()
- Use the "like" operator for all string-valued properties
ignoreCase
public Example ignoreCase()
- Ignore case for all string-valued properties
excludeProperty
public Example excludeProperty(String name)
- Exclude a particular named property
當用enableLike()方法時,可以通過MatchMode指定匹配的方式。MatchMode提供了四種匹配的方式:
Field Summary | |
static MatchMode |
ANYWHERE Match the pattern anywhere in the string |
static MatchMode |
END Match the end of the string to the pattern |
static MatchMode |
EXACT Match the entire string to the pattern |
static MatchMode |
START Match the start of the string to the pattern |