本文整理匯總了Java中org.greenrobot.greendao.database.DatabaseStatement類的典型用法代碼示例。如果您正苦於以下問題:Java DatabaseStatement類的具體用法?Java DatabaseStatement怎麽用?Java DatabaseStatement使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DatabaseStatement類屬於org.greenrobot.greendao.database包,在下文中一共展示了DatabaseStatement類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: executeInsert
import org.greenrobot.greendao.database.DatabaseStatement; //導入依賴的package包/類
private long executeInsert(T entity, DatabaseStatement stmt, boolean setKeyAndAttach) {
long rowId;
if (db.isDbLockedByCurrentThread()) {
rowId = insertInsideTx(entity, stmt);
} else {
// Do TX to acquire a connection before locking the stmt to avoid deadlocks
db.beginTransaction();
try {
rowId = insertInsideTx(entity, stmt);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
if (setKeyAndAttach) {
updateKeyAfterInsertAndAttach(entity, rowId, true);
}
return rowId;
}
示例2: deleteByKey
import org.greenrobot.greendao.database.DatabaseStatement; //導入依賴的package包/類
/** Deletes an entity with the given PK from the database. Currently, only single value PK entities are supported. */
public void deleteByKey(K key) {
assertSinglePk();
DatabaseStatement stmt = statements.getDeleteStatement();
if (db.isDbLockedByCurrentThread()) {
synchronized (stmt) {
deleteByKeyInsideSynchronized(key, stmt);
}
} else {
// Do TX to acquire a connection before locking the stmt to avoid deadlocks
db.beginTransaction();
try {
synchronized (stmt) {
deleteByKeyInsideSynchronized(key, stmt);
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
if (identityScope != null) {
identityScope.remove(key);
}
}
示例3: update
import org.greenrobot.greendao.database.DatabaseStatement; //導入依賴的package包/類
public void update(T entity) {
assertSinglePk();
DatabaseStatement stmt = statements.getUpdateStatement();
if (db.isDbLockedByCurrentThread()) {
synchronized (stmt) {
if (isStandardSQLite) {
updateInsideSynchronized(entity, (SQLiteStatement) stmt.getRawStatement(), true);
} else {
updateInsideSynchronized(entity, stmt, true);
}
}
} else {
// Do TX to acquire a connection before locking the stmt to avoid deadlocks
db.beginTransaction();
try {
synchronized (stmt) {
updateInsideSynchronized(entity, stmt, true);
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
}
示例4: _testThreadLocalSpeed
import org.greenrobot.greendao.database.DatabaseStatement; //導入依賴的package包/類
/**
* We could put the statements inside ThreadLocals (fast enough), but it comes with initialization penalty for new
* threads and costs more memory.
*/
public void _testThreadLocalSpeed() {
final Database db = dao.getDatabase();
ThreadLocal<DatabaseStatement> threadLocal = new ThreadLocal<DatabaseStatement>() {
@Override
protected DatabaseStatement initialValue() {
return db.compileStatement("SELECT 42");
}
};
threadLocal.get();
long start = SystemClock.currentThreadTimeMillis();
for (int i = 0; i < 1000; i++) {
DatabaseStatement sqLiteStatement = threadLocal.get();
assertNotNull(sqLiteStatement);
}
Long time = SystemClock.currentThreadTimeMillis() - start;
DaoLog.d("TIME: " + time + "ms");
// Around 1ms on a S3
assertTrue(time < 10);
}
示例5: testMockitoMocks
import org.greenrobot.greendao.database.DatabaseStatement; //導入依賴的package包/類
@Test
public void testMockitoMocks() {
mock(DaoMaster.class).newSession();
mock(DaoSession.class).getDatabase();
mock(Database.class).getRawDatabase();
mock(DatabaseStatement.class).execute();
mock(IdentityScope.class).clear();
mock(AbstractDao.class).queryBuilder();
mock(MinimalEntityDao.class).queryBuilder();
mock(MinimalEntity.class).getId();
mock(Query.class).forCurrentThread();
mock(QueryBuilder.class).build();
mock(CountQuery.class).forCurrentThread();
mock(DeleteQuery.class).forCurrentThread();
mock(Join.class).getTablePrefix();
mock(LazyList.class).getLoadedCount();
mock(WhereCondition.class).appendValuesTo(null);
mock(Property.class).isNull();
mock(DaoException.class).getMessage();
}
示例6: bindValues
import org.greenrobot.greendao.database.DatabaseStatement; //導入依賴的package包/類
@Override
protected final void bindValues(DatabaseStatement stmt, ToManyTargetEntity entity) {
stmt.clearBindings();
Long toManyId = entity.getToManyId();
if (toManyId != null) {
stmt.bindLong(1, toManyId);
}
Long toManyIdDesc = entity.getToManyIdDesc();
if (toManyIdDesc != null) {
stmt.bindLong(2, toManyIdDesc);
}
Long id = entity.getId();
if (id != null) {
stmt.bindLong(3, id);
}
String targetJoinProperty = entity.getTargetJoinProperty();
if (targetJoinProperty != null) {
stmt.bindString(4, targetJoinProperty);
}
}
示例7: bindValues
import org.greenrobot.greendao.database.DatabaseStatement; //導入依賴的package包/類
@Override
protected final void bindValues(DatabaseStatement stmt, RelationEntity entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
Long parentId = entity.getParentId();
if (parentId != null) {
stmt.bindLong(2, parentId);
}
Long testId = entity.getTestId();
if (testId != null) {
stmt.bindLong(3, testId);
}
stmt.bindLong(4, entity.getTestIdNotNull());
String simpleString = entity.getSimpleString();
if (simpleString != null) {
stmt.bindString(5, simpleString);
}
}
示例8: bindValues
import org.greenrobot.greendao.database.DatabaseStatement; //導入依賴的package包/類
@Override
protected final void bindValues(DatabaseStatement stmt, JoinManyToDateEntity entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
Long idToMany = entity.getIdToMany();
if (idToMany != null) {
stmt.bindLong(2, idToMany);
}
Long idDate = entity.getIdDate();
if (idDate != null) {
stmt.bindLong(3, idDate);
}
}
示例9: bindValues
import org.greenrobot.greendao.database.DatabaseStatement; //導入依賴的package包/類
@Override
protected final void bindValues(DatabaseStatement stmt, RepositoryNote entity) {
stmt.clearBindings();
stmt.bindLong(1, entity.getId());
String name = entity.getName();
if (name != null) {
stmt.bindString(2, name);
}
String username = entity.getUsername();
if (username != null) {
stmt.bindString(3, username);
}
stmt.bindLong(4, entity.getRepos());
}
示例10: bindValues
import org.greenrobot.greendao.database.DatabaseStatement; //導入依賴的package包/類
@Override
protected final void bindValues(DatabaseStatement stmt, County entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
String countyName = entity.getCountyName();
if (countyName != null) {
stmt.bindString(2, countyName);
}
String weatherId = entity.getWeatherId();
if (weatherId != null) {
stmt.bindString(3, weatherId);
}
stmt.bindLong(4, entity.getCityId());
}
示例11: bindValues
import org.greenrobot.greendao.database.DatabaseStatement; //導入依賴的package包/類
@Override
protected final void bindValues(DatabaseStatement stmt, City entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
String cityName = entity.getCityName();
if (cityName != null) {
stmt.bindString(2, cityName);
}
stmt.bindLong(3, entity.getCityCode());
stmt.bindLong(4, entity.getProvinceId());
}
示例12: bindValues
import org.greenrobot.greendao.database.DatabaseStatement; //導入依賴的package包/類
@Override
protected final void bindValues(DatabaseStatement stmt, UserBean entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
stmt.bindString(2, entity.getTitle());
stmt.bindString(3, entity.getFirst());
stmt.bindString(4, entity.getLast());
stmt.bindString(5, entity.getEmail());
stmt.bindString(6, entity.getDob());
stmt.bindString(7, entity.getPhone());
stmt.bindString(8, entity.getCell());
stmt.bindString(9, entity.getThumbnailPic());
stmt.bindString(10, entity.getMediumPic());
stmt.bindString(11, entity.getLargePic());
}
示例13: bindValues
import org.greenrobot.greendao.database.DatabaseStatement; //導入依賴的package包/類
@Override
protected final void bindValues(DatabaseStatement stmt, LocalUser entity) {
stmt.clearBindings();
stmt.bindString(1, entity.getLogin());
String name = entity.getName();
if (name != null) {
stmt.bindString(2, name);
}
String avatarUrl = entity.getAvatarUrl();
if (avatarUrl != null) {
stmt.bindString(3, avatarUrl);
}
Integer followers = entity.getFollowers();
if (followers != null) {
stmt.bindLong(4, followers);
}
Integer following = entity.getFollowing();
if (following != null) {
stmt.bindLong(5, following);
}
}
示例14: bindValues
import org.greenrobot.greendao.database.DatabaseStatement; //導入依賴的package包/類
@Override
protected final void bindValues(DatabaseStatement stmt, Bookmark entity) {
stmt.clearBindings();
stmt.bindString(1, entity.getId());
stmt.bindString(2, entity.getType());
String userId = entity.getUserId();
if (userId != null) {
stmt.bindString(3, userId);
}
Long repoId = entity.getRepoId();
if (repoId != null) {
stmt.bindLong(4, repoId);
}
java.util.Date markTime = entity.getMarkTime();
if (markTime != null) {
stmt.bindLong(5, markTime.getTime());
}
}
示例15: bindValues
import org.greenrobot.greendao.database.DatabaseStatement; //導入依賴的package包/類
@Override
protected final void bindValues(DatabaseStatement stmt, AuthUser entity) {
stmt.clearBindings();
stmt.bindString(1, entity.getAccessToken());
stmt.bindLong(2, entity.getAuthTime().getTime());
stmt.bindLong(3, entity.getExpireIn());
stmt.bindString(4, entity.getScope());
stmt.bindLong(5, entity.getSelected() ? 1L: 0L);
stmt.bindString(6, entity.getLoginId());
String name = entity.getName();
if (name != null) {
stmt.bindString(7, name);
}
String avatar = entity.getAvatar();
if (avatar != null) {
stmt.bindString(8, avatar);
}
}