Skip to content

Instantly share code, notes, and snippets.

@gregorydickson
Last active April 26, 2017 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregorydickson/1c5f3053eafda1a9da498545206c98f9 to your computer and use it in GitHub Desktop.
Save gregorydickson/1c5f3053eafda1a9da498545206c98f9 to your computer and use it in GitHub Desktop.
List results = criteria.listDistinct () {
createAlias('samples','s',CriteriaSpecification.LEFT_JOIN)
createAlias('s.sampleRequests', 'sr', CriteriaSpecification.LEFT_JOIN)
or {
isNull('s.id')
sizeEq('s.sampleRequests', 0)
//Needs to be any samples available, not all samples available.
// In other words check all items in the collection and if they all meet
// the condition then exclude
and{
not{
between('sr.bookingStartDate', availableFrom, availableTo)
}
not{
between('sr.bookingEndDate', availableFrom, availableTo)
}
'in' ('sr.requestStatusBrand',['Approved','Picked Up','Returning'])
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment