Skip to content

Instantly share code, notes, and snippets.

@xcesco
Created October 7, 2018 23:57
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 xcesco/511a057be3c45b556787fd3c77ec016a to your computer and use it in GitHub Desktop.
Save xcesco/511a057be3c45b556787fd3c77ec016a to your computer and use it in GitHub Desktop.
@BindDataSourceOptions(populator = AppDataSourcePopulator.class)
@BindDataSource(version = 1,
daoSet = {CommentDao.class, ProductDao.class},
fileName = "app.db",
typeAdapters = {
@BindSqlAdapter(adapter = DateMillisecondsTypeAdapter.class)}
)
public interface AppDataSource {
}
@BindDao(ProductEntity.class)
public interface ProductDao extends AbstractDao<ProductEntity> {
@BindSqlSelect(orderBy = "name")
MutableLiveData<List<ProductEntity>> loadAllProducts();
@BindSqlSelect(where = "id = :productId")
MutableLiveData<ProductEntity> loadProduct(long productId);
@BindSqlSelect(where = "id = :productId")
ProductEntity loadProductSync(long productId);
@BindSqlSelect(orderBy = "name", pageSize = 1)
ProductEntity selectFirst();
@BindSqlDelete(where = "id=:{bean.id}")
int delete(ProductEntity bean);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment