Created
October 1, 2018 11:50
-
-
Save xcesco/7c49f5aeb42dc58c2c54b1352bd5cce7 to your computer and use it in GitHub Desktop.
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
@BindDao(Book.class) | |
public interface BookDao { | |
@BindSqlSelect(where="id = :id") | |
Book loadBookById(int id); | |
@BindSqlSelect(jql="SELECT * FROM Book " + | |
"INNER JOIN Loan ON Loan.bookId = Book.id " + | |
"INNER JOIN User on User.id = Loan.userId " + | |
"WHERE User.name LIKE :userName" | |
) | |
LiveData<List<Book>> findBooksBorrowedByName(String userName); | |
@BindSqlSelect(jql="SELECT * FROM Book " + | |
"INNER JOIN Loan ON Loan.bookId = Book.id " + | |
"INNER JOIN User on User.id = Loan.userId " + | |
"WHERE User.name LIKE :userName " + | |
"AND Loan.endTime > :after " | |
) | |
LiveData<List<Book>> findBooksBorrowedByNameAfter(String userName, Date after); | |
@BindSqlSelect(jql="SELECT * FROM Book " + | |
"INNER JOIN Loan ON Loan.bookId = Book.id " + | |
"INNER JOIN User on User.id = Loan.userId " + | |
"WHERE User.name LIKE :userName" | |
) | |
List<Book> findBooksBorrowedByNameSync(String userName); | |
@BindSqlSelect(jql="SELECT * FROM Book " + | |
"INNER JOIN Loan ON Loan.bookId LIKE Book.id " + | |
"WHERE Loan.userId LIKE :userId " | |
) | |
LiveData<List<Book>> findBooksBorrowedByUser(String userId); | |
@BindSqlSelect(jql="SELECT * FROM Book " + | |
"INNER JOIN Loan ON Loan.bookId LIKE Book.id " + | |
"WHERE Loan.userId LIKE :userId " + | |
"AND Loan.endTime > :after " | |
) | |
LiveData<List<Book>> findBooksBorrowedByUserAfter(String userId, @BindSqlParam(adapter= DateTimeMillisecondsTypeAdapter.class) Date after); | |
@BindSqlSelect(jql="SELECT * FROM Book " + | |
"INNER JOIN Loan ON Loan.bookId LIKE Book.id " + | |
"WHERE Loan.userId = :userId " | |
) | |
List<Book> findBooksBorrowedByUserSync(String userId); | |
@BindSqlSelect | |
LiveData<List<Book>> findAllBooks(); | |
@BindSqlSelect | |
List<Book> findAllBooksSync(); | |
@BindSqlInsert(conflictAlgorithm = ConflictAlgorithmType.IGNORE) | |
void insertBook(Book book); | |
@BindSqlUpdate(conflictAlgorithm = ConflictAlgorithmType.REPLACE) | |
void updateBook(Book book); | |
@BindSqlDelete | |
void deleteAll(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment