The Update annotation is used to decorate a Query interface method to update one or more records in a database table.
An Update annotation must include a sql annotation type element.
Sample Code
Java
1
2
3
4
interfaceLoanAppDetailsQueryextendsBaseQuery{
@Update(sql="update LoanDetails set LoanStatus = ?1 where loanId = ?2")
Here’s an example of Select annotation to get all the active loans from the loan database:
Sample Code
Java
1
2
3
4
interfaceLoanAppDetailsQueryextendsBaseQuery{
@Select("SELECT * FROM LoanDetais where LoanStatus = 'A'")
DataSet<LoanApplication>getAllActiveLoans();
}
The sql annotation allows I/O parameters as well (a parameter marker is represented with a question mark followed by an integer). Here’s an example of a parameterized sql query.
Sample Code
Java
1
2
3
4
interfaceLoanAppDetailsQueryextendsBaseQuery{
@Select(sql="SELECT * from LoanDetails where borrowerFirstName= ?1 and borrowerLastName= ?2")