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


Java QueryBuilder.where方法代码示例

本文整理汇总了Java中com.j256.ormlite.stmt.QueryBuilder.where方法的典型用法代码示例。如果您正苦于以下问题:Java QueryBuilder.where方法的具体用法?Java QueryBuilder.where怎么用?Java QueryBuilder.where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.j256.ormlite.stmt.QueryBuilder的用法示例。


在下文中一共展示了QueryBuilder.where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getByInterval

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
public List<MerchantService> getByInterval(Date begin, Date end, boolean orderAscending) throws IOException {

        try {
            QueryBuilder<MerchantService, String> queryBuilder = dao.queryBuilder();
            queryBuilder.orderBy(MerchantService.PURCHASE_DATE_FIELD_NAME, orderAscending);
            Where<MerchantService, String> where = queryBuilder.where();
            where.between(MerchantService.PURCHASE_DATE_FIELD_NAME, begin, end);

            List<MerchantService> results = queryBuilder.query();

            for (MerchantService r : results) {
                refresh(r);
            }

            return results;
        } catch (Exception e) {
            throw new IOException(e);
        }
    }
 
开发者ID:remipassmoilesel,项目名称:simple-hostel-management,代码行数:20,代码来源:MerchantServiceService.java

示例2: getTag

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
public Tag getTag(final String aTag) {
    try {
        QueryBuilder<Tag, Long> queryBuilder = dbHelper.getTagDao().queryBuilder();
        Where<Tag, Long> where = queryBuilder.where();
        SelectArg selectArg = new SelectArg();

        // define our query as 'name = ?'
        where.eq(Tag.COLUMN_NAME_TITLE, selectArg);

        // prepare it so it is ready for later query or iterator calls
        PreparedQuery<Tag> preparedQuery = queryBuilder.prepare();

        // later we can set the select argument and issue the query
        selectArg.setValue(aTag);
        List<Tag> tgs = dbHelper.getTagDao().query(preparedQuery);
        if (!tgs.isEmpty()) {
            return tgs.get(0);
        }
    } catch (java.sql.SQLException pE) {
        pE.printStackTrace();
    }
    return null;
}
 
开发者ID:mrspaceman,项目名称:ebookmgr,代码行数:24,代码来源:LibraryManager.java

示例3: getBook

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
public EBook getBook(final String fullFilename) {
    EBook ebk = null;
    try {
        QueryBuilder<EBook, Long> queryBuilder = dbHelper.getEBookDao().queryBuilder();
        Where<EBook, Long> where = queryBuilder.where();
        SelectArg selectArg = new SelectArg();

        // define our query as 'name = ?'
        where.eq(EBook.COLUMN_FULL_FILE_NAME, selectArg);

        // prepare it so it is ready for later query or iterator calls
        PreparedQuery<EBook> preparedQuery = queryBuilder.prepare();

        // later we can set the select argument and issue the query
        selectArg.setValue(fullFilename);
        List<EBook> result = dbHelper.getEBookDao().query(preparedQuery);

        if (result.size() > 0) {
            ebk = result.get(0);
        }
    } catch (java.sql.SQLException pE) {
        BookLibApplication.getInstance().e("Exception reading ebooks", pE);
    }
    return ebk;
}
 
开发者ID:mrspaceman,项目名称:ebookmgr,代码行数:26,代码来源:LibraryManager.java

示例4: getFileType

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
public FileType getFileType(final String aFileType) {
    try {
        QueryBuilder<FileType, Long> queryBuilder = dbHelper.getFileTypeDao().queryBuilder();
        Where<FileType, Long> where = queryBuilder.where();
        SelectArg selectArg = new SelectArg();

        // define our query as 'name = ?'
        where.eq(FileType.COLUMN_NAME_TITLE, selectArg);

        // prepare it so it is ready for later query or iterator calls
        PreparedQuery<FileType> preparedQuery = queryBuilder.prepare();

        // later we can set the select argument and issue the query
        selectArg.setValue(aFileType);
        List<FileType> tgs = dbHelper.getFileTypeDao().query(preparedQuery);
        if (!tgs.isEmpty()) {
            return tgs.get(0);
        }
    } catch (java.sql.SQLException pE) {
        pE.printStackTrace();
    }
    return null;
}
 
开发者ID:mrspaceman,项目名称:ebookmgr,代码行数:24,代码来源:LibraryManager.java

示例5: getAuthor

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
public Author getAuthor(final String pFirstname, final String pLastname) {
    try {
        QueryBuilder<Author, Long> queryBuilder = dbHelper.getAuthorDao().queryBuilder();
        Where<Author, Long> where = queryBuilder.where();
        SelectArg selectArg = new SelectArg();

        // define our query as 'name = ?'
        where.eq(Author.COLUMN_NAME_FIRSTNAME, selectArg);

        // prepare it so it is ready for later query or iterator calls
        PreparedQuery<Author> preparedQuery = queryBuilder.prepare();

        // later we can set the select argument and issue the query
        selectArg.setValue(pFirstname);
        List<Author> tgs = dbHelper.getAuthorDao().query(preparedQuery);
        if (!tgs.isEmpty()) {
            return tgs.get(0);
        }
    } catch (java.sql.SQLException pE) {
        pE.printStackTrace();
    }
    return null;
}
 
开发者ID:mrspaceman,项目名称:ebookmgr,代码行数:24,代码来源:LibraryManager.java

示例6: searchBooksMatching

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
public List<EBook> searchBooksMatching(final String searchStr) {
    List<EBook> result = new ArrayList<>();
    try {
        QueryBuilder<EBook, Long> queryBuilder = dbHelper.getEBookDao().queryBuilder();
        Where<EBook, Long> where = queryBuilder.where();
        SelectArg selectArg2 = new SelectArg();
        selectArg2.setValue("%" + searchStr + "%");
        SelectArg selectArg1 = new SelectArg();
        selectArg1.setValue("%" + searchStr + "%");

        // define our query as 'name = ?'
        where.like(EBook.COLUMN_FULL_FILE_NAME, selectArg1).or()
                .like(EBook.COLUMN_BOOK_TITLE, selectArg2);

        // prepare it so it is ready for later query or iterator calls
        PreparedQuery<EBook> preparedQuery = queryBuilder.prepare();

        // later we can set the select argument and issue the query
        result = dbHelper.getEBookDao().query(preparedQuery);
    } catch (SQLException pE) {
        pE.printStackTrace();
    }

    return result;
}
 
开发者ID:mrspaceman,项目名称:ebookmgr,代码行数:26,代码来源:LibraryManager.java

示例7: queryForPagesByOrder

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
/**
 * 分页排序查询
 *
 * @param columnName  查询条件列名
 * @param value       查询条件值
 * @param orderColumn 排序列名
 * @param ascending   true为升序,false为降序
 * @param offset      搜索下标
 * @param count       搜索条数
 * @return 分页查询后的数据集
 */
public List<T> queryForPagesByOrder(String columnName, Object value, String orderColumn, boolean ascending, Long offset, Long count) {
    List<T> list = null;
    QueryBuilder queryBuilder = ormLiteDao.queryBuilder();
    Where where = queryBuilder.where();
    try {
        where.eq(columnName, value);
        queryBuilder.orderBy(orderColumn, ascending);
        queryBuilder.offset(offset);
        queryBuilder.limit(count);
        list = queryBuilder.query();
    } catch (SQLException e) {
        LogUtils.e(e);
    }
    return list;
}
 
开发者ID:lujianzhao,项目名称:AndroidBase,代码行数:27,代码来源:OrmLiteDao.java

示例8: getBranchBookings

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
/**
 * Returns all the bookings for a given branch in the SQLite database
 *
 * @param currentBranch the specified branch
 * @return a list of the matching bookings
 */
@Override
public List<Booking> getBranchBookings(Branch currentBranch) {
    try {
        QueryBuilder<Booking, Integer> statementBuilder = dao.queryBuilder();
        Where whereClause = statementBuilder.where();

        whereClause.eq(Booking.BRANCH_FIELD_NAME, currentBranch);

        statementBuilder.orderBy(Booking.START_DAY_FIELD_NAME, true);

        return dao.query(statementBuilder.prepare());
    } catch (SQLException e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:AlexisChevalier,项目名称:CarRental-Distributed-System,代码行数:23,代码来源:BookingDaoSqliteImpl.java

示例9: searchBranchVehiclesByType

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
/**
 * Returns all the vehicles matching a type in the specified branch in the SQLite database
 *
 * @param vehicleTypeId the type ID
 * @param nodeBranch the branch
 * @return a list of the matched vehicles
 */
@Override
public List<Vehicle> searchBranchVehiclesByType(int vehicleTypeId, Branch nodeBranch) {
    try {
        QueryBuilder<Vehicle, Integer> statementBuilder = dao.queryBuilder();

        Where whereClause = statementBuilder.where();

        whereClause
                .eq(Vehicle.TYPE_FIELD_NAME, vehicleTypeId)
                .and()
                .eq(Vehicle.BRANCH_FIELD_NAME, nodeBranch);

        return dao.query(statementBuilder.prepare());
    } catch (SQLException e) {
        return null;
    }
}
 
开发者ID:AlexisChevalier,项目名称:CarRental-Distributed-System,代码行数:25,代码来源:VehicleDaoSqliteImpl.java

示例10: deleteCareportalEventById

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
public void deleteCareportalEventById(String _id) {
    try {
        QueryBuilder<CareportalEvent, Long> queryBuilder = null;
        queryBuilder = getDaoCareportalEvents().queryBuilder();
        Where where = queryBuilder.where();
        where.eq("_id", _id);
        PreparedQuery<CareportalEvent> preparedQuery = queryBuilder.prepare();
        List<CareportalEvent> list = getDaoCareportalEvents().query(preparedQuery);

        if (list.size() == 1) {
            CareportalEvent record = list.get(0);
            if (Config.logIncommingData)
                log.debug("Removing CareportalEvent record from database: " + record.log());
            delete(record);
        } else {
            if (Config.logIncommingData)
                log.debug("CareportalEvent not found database: " + _id);
        }
    } catch (SQLException e) {
        log.error("Unhandled exception", e);
    }
}
 
开发者ID:MilosKozak,项目名称:AndroidAPS,代码行数:23,代码来源:DatabaseHelper.java

示例11: getTemptargetsDataFromTime

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的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

示例12: findProfileSwitchById

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
public ProfileSwitch findProfileSwitchById(String _id) {
    try {
        QueryBuilder<ProfileSwitch, Long> queryBuilder = getDaoProfileSwitch().queryBuilder();
        Where where = queryBuilder.where();
        where.eq("_id", _id);
        PreparedQuery<ProfileSwitch> preparedQuery = queryBuilder.prepare();
        List<ProfileSwitch> list = getDaoProfileSwitch().query(preparedQuery);

        if (list.size() == 1) {
            return list.get(0);
        } else {
            return null;
        }
    } catch (SQLException e) {
        log.error("Unhandled exception", e);
    }
    return null;
}
 
开发者ID:MilosKozak,项目名称:AndroidAPS,代码行数:19,代码来源:DatabaseHelper.java

示例13: getLastCareportalEvent

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
@Nullable
public CareportalEvent getLastCareportalEvent(String event) {
    try {
        List<CareportalEvent> careportalEvents;
        QueryBuilder<CareportalEvent, Long> queryBuilder = getDaoCareportalEvents().queryBuilder();
        queryBuilder.orderBy("date", false);
        Where where = queryBuilder.where();
        where.eq("eventType", event);
        queryBuilder.limit(1L);
        PreparedQuery<CareportalEvent> preparedQuery = queryBuilder.prepare();
        careportalEvents = getDaoCareportalEvents().query(preparedQuery);
        if (careportalEvents.size() == 1)
            return careportalEvents.get(0);
        else
            return null;
    } catch (SQLException e) {
        log.error("Unhandled exception", e);
    }
    return null;
}
 
开发者ID:MilosKozak,项目名称:AndroidAPS,代码行数:21,代码来源:DatabaseHelper.java

示例14: updateDanaRHistoryRecordId

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
public void updateDanaRHistoryRecordId(JSONObject trJson) {
    try {
        QueryBuilder<DanaRHistoryRecord, String> queryBuilder = getDaoDanaRHistory().queryBuilder();
        Where where = queryBuilder.where();
        where.ge("bytes", trJson.get(DanaRNSHistorySync.DANARSIGNATURE));
        PreparedQuery<DanaRHistoryRecord> preparedQuery = queryBuilder.prepare();
        List<DanaRHistoryRecord> list = getDaoDanaRHistory().query(preparedQuery);
        if (list.size() == 0) {
            // Record does not exists. Ignore
        } else if (list.size() == 1) {
            DanaRHistoryRecord record = list.get(0);
            if (record._id == null || !record._id.equals(trJson.getString("_id"))) {
                if (Config.logIncommingData)
                    log.debug("Updating _id in DanaR history database: " + trJson.getString("_id"));
                record._id = trJson.getString("_id");
                getDaoDanaRHistory().update(record);
            } else {
                // already set
            }
        }
    } catch (SQLException | JSONException e) {
        log.error("Unhandled exception", e);
    }
}
 
开发者ID:MilosKozak,项目名称:AndroidAPS,代码行数:25,代码来源:DatabaseHelper.java

示例15: findExtendedBolusById

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
public ExtendedBolus findExtendedBolusById(String _id) {
    try {
        QueryBuilder<ExtendedBolus, Long> queryBuilder = null;
        queryBuilder = getDaoExtendedBolus().queryBuilder();
        Where where = queryBuilder.where();
        where.eq("_id", _id);
        PreparedQuery<ExtendedBolus> preparedQuery = queryBuilder.prepare();
        List<ExtendedBolus> list = getDaoExtendedBolus().query(preparedQuery);

        if (list.size() == 1) {
            return list.get(0);
        } else {
            return null;
        }
    } catch (SQLException e) {
        log.error("Unhandled exception", e);
    }
    return null;
}
 
开发者ID:MilosKozak,项目名称:AndroidAPS,代码行数:20,代码来源:DatabaseHelper.java


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