Last active
August 29, 2015 14:22
-
-
Save biniama/ac2fca32f6a5be2c21c6 to your computer and use it in GitHub Desktop.
Example of Using Hibernate Create Criteria for a complex query in Grails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<Account> getListOfCustomersForSearchCustomer(String firstName, String lastName, String phoneNumber, String accountNumber) | |
{ | |
return Account.createCriteria().list { | |
or { | |
eq("accountNumber", accountNumber) | |
user { | |
or { | |
eq("firstName", firstName) | |
eq("lastName", lastName) | |
eq("phoneNumber", phoneNumber) | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This method RETURNS the list of accounts WHERE Account.accountNumber equals the same as parameter value OR + EITHER firstName, lastName OR phoneNumber are same as User.firstName, User.lastName OR User.phoneNumber.