Skip to content

Instantly share code, notes, and snippets.

@tkh44
Last active August 29, 2015 14:09
Show Gist options
  • Save tkh44/6af5e50dc95a3f746d8c to your computer and use it in GitHub Desktop.
Save tkh44/6af5e50dc95a3f746d8c to your computer and use it in GitHub Desktop.
this is fun
newOptions += search.map((search: String) => {
val splitString: Array[String] = search.trim.split(" ")
val conjunction = Restrictions.conjunction
for (term <- splitString; disjunction = Restrictions.disjunction; searchString = "%" + term + "%" if term.nonEmpty) {
Array("name", "description") foreach((field) => disjunction.add(Restrictions.like(field, searchString)))
conjunction.add(disjunction)
}
conjunction
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment