本文整理汇总了Java中com.j256.ormlite.dao.Dao.queryBuilder方法的典型用法代码示例。如果您正苦于以下问题:Java Dao.queryBuilder方法的具体用法?Java Dao.queryBuilder怎么用?Java Dao.queryBuilder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.j256.ormlite.dao.Dao
的用法示例。
在下文中一共展示了Dao.queryBuilder方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: lastBg
import com.j256.ormlite.dao.Dao; //导入方法依赖的package包/类
@Nullable
public static BgReading lastBg() {
List<BgReading> bgList = null;
try {
Dao<BgReading, Long> daoBgReadings = MainApp.getDbHelper().getDaoBgReadings();
QueryBuilder<BgReading, Long> queryBuilder = daoBgReadings.queryBuilder();
queryBuilder.orderBy("date", false);
queryBuilder.limit(1L);
queryBuilder.where().gt("value", 38);
PreparedQuery<BgReading> preparedQuery = queryBuilder.prepare();
bgList = daoBgReadings.query(preparedQuery);
} catch (SQLException e) {
log.debug(e.getMessage(), e);
}
if (bgList != null && bgList.size() > 0)
return bgList.get(0);
else
return null;
}
示例2: getBgreadingsDataFromTime
import com.j256.ormlite.dao.Dao; //导入方法依赖的package包/类
public List<BgReading> getBgreadingsDataFromTime(long mills, boolean ascending) {
try {
Dao<BgReading, Long> daoBgreadings = getDaoBgReadings();
List<BgReading> bgReadings;
QueryBuilder<BgReading, Long> queryBuilder = daoBgreadings.queryBuilder();
queryBuilder.orderBy("date", ascending);
Where where = queryBuilder.where();
where.ge("date", mills).and().gt("value", 38);
PreparedQuery<BgReading> preparedQuery = queryBuilder.prepare();
bgReadings = daoBgreadings.query(preparedQuery);
return bgReadings;
} catch (SQLException e) {
log.error("Unhandled exception", e);
}
return new ArrayList<BgReading>();
}
示例3: findTreatmentById
import com.j256.ormlite.dao.Dao; //导入方法依赖的package包/类
@Nullable
public Treatment findTreatmentById(String _id) {
try {
Dao<Treatment, Long> daoTreatments = getDaoTreatments();
QueryBuilder<Treatment, Long> queryBuilder = daoTreatments.queryBuilder();
Where where = queryBuilder.where();
where.eq("_id", _id);
queryBuilder.limit(10L);
PreparedQuery<Treatment> preparedQuery = queryBuilder.prepare();
List<Treatment> trList = daoTreatments.query(preparedQuery);
if (trList.size() != 1) {
//log.debug("Treatment findTreatmentById query size: " + trList.size());
return null;
} else {
//log.debug("Treatment findTreatmentById found: " + trList.get(0).log());
return trList.get(0);
}
} catch (SQLException e) {
log.error("Unhandled exception", e);
}
return null;
}
示例4: getTreatmentDataFromTime
import com.j256.ormlite.dao.Dao; //导入方法依赖的package包/类
public List<Treatment> getTreatmentDataFromTime(long mills, boolean ascending) {
try {
Dao<Treatment, Long> daoTreatments = getDaoTreatments();
List<Treatment> treatments;
QueryBuilder<Treatment, Long> queryBuilder = daoTreatments.queryBuilder();
queryBuilder.orderBy("date", ascending);
Where where = queryBuilder.where();
where.ge("date", mills);
PreparedQuery<Treatment> preparedQuery = queryBuilder.prepare();
treatments = daoTreatments.query(preparedQuery);
return treatments;
} catch (SQLException e) {
log.error("Unhandled exception", e);
}
return new ArrayList<Treatment>();
}
示例5: getTemptargetsDataFromTime
import com.j256.ormlite.dao.Dao; //导入方法依赖的package包/类
public List<TempTarget> getTemptargetsDataFromTime(long mills, boolean ascending) {
try {
Dao<TempTarget, Long> daoTempTargets = getDaoTempTargets();
List<TempTarget> tempTargets;
QueryBuilder<TempTarget, Long> queryBuilder = daoTempTargets.queryBuilder();
queryBuilder.orderBy("date", ascending);
Where where = queryBuilder.where();
where.ge("date", mills);
PreparedQuery<TempTarget> preparedQuery = queryBuilder.prepare();
tempTargets = daoTempTargets.query(preparedQuery);
return tempTargets;
} catch (SQLException e) {
log.error("Unhandled exception", e);
}
return new ArrayList<TempTarget>();
}
示例6: bucketOps
import com.j256.ormlite.dao.Dao; //导入方法依赖的package包/类
public static void bucketOps(String path, Boolean bucket, Context mContext) {
final OrmHandler ormHandler = OpenHelperManager.getHelper(mContext, OrmHandler.class);
try {
Dao<Track, String> dbTrack = ormHandler.getDao(Track.class);
QueryBuilder<Track, String> queryBuilder = dbTrack.queryBuilder();
SelectArg selectArg = new SelectArg();
queryBuilder.where().eq("path", selectArg);
PreparedQuery<Track> preparedQuery = queryBuilder.prepare();
selectArg.setValue(path);
List<Track> lister = dbTrack.query(preparedQuery);
Track temp_track = lister.get(0);
temp_track.setBucket(bucket);
dbTrack.update(temp_track);
BUCKET_OPS = true;
} catch (SQLException | IndexOutOfBoundsException e) {
e.printStackTrace();
}
}
示例7: getFoodData
import com.j256.ormlite.dao.Dao; //导入方法依赖的package包/类
public List<Food> getFoodData() {
try {
Dao<Food, Long> daoFood = getDaoFood();
List<Food> foods;
QueryBuilder<Food, Long> queryBuilder = daoFood.queryBuilder();
PreparedQuery<Food> preparedQuery = queryBuilder.prepare();
foods = daoFood.query(preparedQuery);
return foods;
} catch (SQLException e) {
log.error("Unhandled exception", e);
}
return new ArrayList<>();
}
示例8: getProfileSwitchData
import com.j256.ormlite.dao.Dao; //导入方法依赖的package包/类
public List<ProfileSwitch> getProfileSwitchData(boolean ascending) {
try {
Dao<ProfileSwitch, Long> daoProfileSwitch = getDaoProfileSwitch();
List<ProfileSwitch> profileSwitches;
QueryBuilder<ProfileSwitch, Long> queryBuilder = daoProfileSwitch.queryBuilder();
queryBuilder.orderBy("date", ascending);
queryBuilder.limit(20L);
PreparedQuery<ProfileSwitch> preparedQuery = queryBuilder.prepare();
profileSwitches = daoProfileSwitch.query(preparedQuery);
return profileSwitches;
} catch (SQLException e) {
log.error("Unhandled exception", e);
}
return new ArrayList<ProfileSwitch>();
}
示例9: queriedTracks
import com.j256.ormlite.dao.Dao; //导入方法依赖的package包/类
public void queriedTracks(String query) {
OrmHandler orm = OpenHelperManager.getHelper(mContext, OrmHandler.class);
try {
Dao<Track, String> mTrack = orm.getDao(Track.class);
QueryBuilder<Track, String> queryBuilder = mTrack.queryBuilder();
queryBuilder.where().like("name", "%" + query + "%").or().like("artist", "%" + query + "%").or().like("album", "%" + query + "%");
PreparedQuery<Track> preparedQuery = queryBuilder.prepare();
mTrackList = mTrack.query(preparedQuery);
} catch (SQLException e) {
e.printStackTrace();
}
OpenHelperManager.releaseHelper();
notifyDataSetChanged();
}
示例10: DeviceQueryBuilder
import com.j256.ormlite.dao.Dao; //导入方法依赖的package包/类
/**
* Creates builder for device selection query by a given device data access object and {@link DeviceSelector
* selector}.
*
* @param deviceDao
* - object for accessing data about stored devices in the database
* @param selector
* - contains all device parameters used for device matching
*/
public DeviceQueryBuilder(Dao<Device, String> deviceDao, DeviceSelector selector) {
deviceQueryBuilder = deviceDao.queryBuilder();
deviceWhereClause = deviceQueryBuilder.where();
criteriaCount = 0;
selector.visitAll(this);
}