本文整理匯總了Java中com.j256.ormlite.dao.Dao.query方法的典型用法代碼示例。如果您正苦於以下問題:Java Dao.query方法的具體用法?Java Dao.query怎麽用?Java Dao.query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.j256.ormlite.dao.Dao
的用法示例。
在下文中一共展示了Dao.query方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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();
}