Skip to content

Instantly share code, notes, and snippets.

@BindType("item")
@BindXmlType(namespaces={
@BindXmlNamespace(prefix="dc",uri="http://purl.org/dc/elements/1.1/"),
@BindXmlNamespace(prefix="content",uri="http://purl.org/dc/elements/1.1/"),
})
@BindSqlType(name = "articles")
public class Article extends Entity {
public String title;
public String description;
public URL link;
@BindDataSourceOptions(populator = AppDataSourcePopulator.class)
@BindDataSource(version = 1,
daoSet = {CommentDao.class, ProductDao.class},
fileName = "app.db",
log = false,
typeAdapters = {
@BindSqlAdapter(adapter = DateMillisecondsTypeAdapter.class)}
)
public interface AppDataSource {
}
I/ProductDaoImpl, insert (line 94): INSERT OR REPLACE INTO products (description, name, price) VALUES (:description, :name, :price)
I/ProductDaoImpl, insert (line 103): ==> :description = 'Special edition Three-headed Monkey is finally here' (java.lang.String)
==> :name = 'Special edition Three-headed Monkey' (java.lang.String)
==> :price = '109' (java.lang.Integer)
I/ProductDaoImpl, insert (line 94): INSERT OR REPLACE INTO products (description, name, price) VALUES (:description, :name, :price)
I/ProductDaoImpl, insert (line 103): ==> :description = 'Special edition Rubber Chicken is recommended by Stan S. Stanman' (java.lang.String)
I/ProductDaoImpl, insert (line 103): ==> :name = 'Special edition Rubber Chicken' (java.lang.String)
==> :price = '128' (java.lang.Integer)
I/ProductDaoImpl, insert (line 94): INSERT OR REPLACE INTO products (description, name, price) VALUES (:description, :name, :price)
I/ProductDaoImpl, insert (line 103): ==> :description = 'Special edition Pint of Grog is the best
@BindDataSourceOptions(populator = AppDataSourcePopulator.class)
@BindDataSource(version = 1,
daoSet = {CommentDao.class, ProductDao.class},
fileName = "app.db",
typeAdapters = {
@BindSqlAdapter(adapter = DateMillisecondsTypeAdapter.class)}
)
public interface AppDataSource {
}
@xcesco
xcesco / Album.java
Created September 28, 2018 23:16
III case
@BindSqlType
public class Album {
@BindSqlColumn(columnType=ColumnType.PRIMARY_KEY_UNMANGED)
public String name;
public Date year;
}
@xcesco
xcesco / DaoPerson.java
Created September 28, 2018 23:02
parameter in query string can be ${placeHolder} or :{placeHolder} or :placeHolder
@BindDao(Person.class)
public interface DaoPerson {
@BindSqlSelect(where="name=${name}")
List<Person> select1(String name);
@BindSqlSelect(where="name=:{name}")
List<Person> select2(String name);
@BindSqlSelect(where="name=:name")
List<Person> select3(String name);
@xcesco
xcesco / AlbumDao.java
Created September 28, 2018 23:10
Parameter in content provider URL can be ${placeHolder} or :{placeHolder} or :placeHolder
@BindContentProviderPath(path = "albums")
@BindDao(Album.class)
public interface AlbumDao extends BaseDao<Album> {
@BindContentProviderEntry(path = ":{id}")
@BindSqlSelect(where = "id=:{id}")
List<Album> select(long id);
}
@BindDataSource(fileName="app.db", version=1, daoSet={DaoPerson.class})
public interface AppDataSource {
/**
* @param daoPerson
* is injected by kripton
* @param name
* is
*/
@BindTransaction
@BindDao(Person.class)
public interface DaoPerson {
@BindSqlSelect(where = "name like ${name} || '%'")
PagedLiveData<List<Person>> selectPaged(String name);
@BindSqlInsert
void insert(Person bean);
@BindSqlUpdate(where = "id=${bean.id}")
@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"