Skip to content

Instantly share code, notes, and snippets.

@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 {
}
@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"
@BindDao(Person.class)
public interface DaoPerson {
@BindSqlSelect(orderBy = "name", pageSize = 10)
PagedResult<Person> select();
@BindSqlInsert
void insertOne(String pk, String name, String surname, String birthCity, Date birthDay);
@BindSqlSelect(orderBy = "name")
public Future<Boolean> executeAsync(final Transaction transaction)
public Future<Boolean> executeAsync(final Transaction transaction, final AbstractDataSource.OnErrorListener onErrorListener)
public <T> Future<T> executeBatchAsync(final Batch<T> commands)
public <T> Future<T> executeBatchAsync(final Batch<T> commands, final boolean writeMode)
@xcesco
xcesco / DaoCity.java
Created October 1, 2018 11:29
Kripton ORM: select in example
// DAO definition
@BindDao(City.class)
public interface DaoCity {
@BindSqlInsert
long insert(City bean);
@BindSqlSelect(where="id in (:{dummy})")
List<City> selectAll2(@BindSqlParam("dummy") List<Long> args);
}
@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;
}