当前位置: 首页>>代码示例>>Java>>正文


Java Dao.queryBuilder方法代码示例

本文整理汇总了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;
}
 
开发者ID:MilosKozak,项目名称:AndroidAPS,代码行数:22,代码来源:DatabaseHelper.java

示例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>();
}
 
开发者ID:MilosKozak,项目名称:AndroidAPS,代码行数:17,代码来源:DatabaseHelper.java

示例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;
}
 
开发者ID:MilosKozak,项目名称:AndroidAPS,代码行数:23,代码来源:DatabaseHelper.java

示例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>();
}
 
开发者ID:MilosKozak,项目名称:AndroidAPS,代码行数:17,代码来源:DatabaseHelper.java

示例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>();
}
 
开发者ID:MilosKozak,项目名称:AndroidAPS,代码行数:17,代码来源:DatabaseHelper.java

示例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();
    }
}
 
开发者ID:Circle-Of-Music-Makers,项目名称:com-android,代码行数:19,代码来源:Utils.java

示例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<>();
}
 
开发者ID:MilosKozak,项目名称:AndroidAPS,代码行数:14,代码来源:FoodHelper.java

示例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>();
}
 
开发者ID:MilosKozak,项目名称:AndroidAPS,代码行数:16,代码来源:DatabaseHelper.java

示例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();
}
 
开发者ID:Circle-Of-Music-Makers,项目名称:com-android,代码行数:15,代码来源:TracksAdapter.java

示例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);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:17,代码来源:DeviceQueryBuilder.java


注:本文中的com.j256.ormlite.dao.Dao.queryBuilder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。