Skip to content

Instantly share code, notes, and snippets.

@bhawna94
Last active June 6, 2019 10:15
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 bhawna94/2f29a738dc054a298e730d04b6c7b55b to your computer and use it in GitHub Desktop.
Save bhawna94/2f29a738dc054a298e730d04b6c7b55b to your computer and use it in GitHub Desktop.
public List<Employee> getEmployeeUsingCustomQuery(String name) {
//creating query on the basis of empName
String statement = "select empName, empId, META().id AS _ID, META().cas AS _CAS from Bucket1 where empName=$empName";
JsonObject placeHolder = JsonObject.create().put("empName", name);
N1qlQuery n1qlQuery = N1qlQuery.parameterized(statement, placeHolder);
//findbyN1QL method query the N!QL service and mapped to the Employee class.
return couchbaseTemplate.findByN1QL(n1qlQuery, Employee.class);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment