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


Java MySQL.addLikeClause方法代码示例

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


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

示例1: getItems

import org.easyrec.utils.io.MySQL; //导入方法依赖的package包/类
@Override
public List<Item> getItems(RemoteTenant remoteTenant, String description, int start, int end) {
    List<Item> items;

    Object[] args = {remoteTenant.getId(), Item.DEFAULT_STRING_ITEM_TYPE};
    int[] argTypes = {Types.INTEGER, Types.VARCHAR};

    StringBuilder sql = new StringBuilder(SQL_GET_ITEMS);
    sql = MySQL.addLikeClause(sql, "DESCRIPTION", description);
    sql = MySQL.addLimitClause(sql, start, end);

    try {
        items = getJdbcTemplate().query(sql.toString(), args, argTypes, itemRowMapper);

        for (final Object item1 : items) {
            Item item = (Item) item1;
            item.setUrl(Text.matchMax(remoteTenant.getUrl(), item.getUrl()));
            item.setImageUrl(Text.matchMax(remoteTenant.getUrl(), item.getImageUrl()));
        }

        return items;
    } catch (Exception e) {
        logger.warn("An error occurred!", e);
        return null;
    }
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:27,代码来源:ItemDAOMysqlImpl.java

示例2: getItemsWithRules

import org.easyrec.utils.io.MySQL; //导入方法依赖的package包/类
@Override
public List<Item> getItemsWithRules(Integer tenantId, String description, int start, int end) {
    StringBuilder sql = new StringBuilder().append(" SELECT ").append(" 	i.* ").append(" FROM  ")
            .append(" 	item i INNER JOIN ( ")
            .append(" 	SELECT stringid FROM (SELECT distinct itemFromId FROM itemassoc WHERE tenantid = ?");

    if (Strings.isNullOrEmpty(description))
        sql = MySQL.addLimitClause(sql, start, end);

    sql.append(") a INNER JOIN idmapping m ON (m.intId = a.itemFromId)) a ")
            .append("   	ON (i.itemid = stringid AND tenantid=?) ").append("  WHERE 1=1");
    sql = MySQL.addLikeClause(sql, "i.DESCRIPTION", description);

    if (!Strings.isNullOrEmpty(description))
        sql = MySQL.addLimitClause(sql, start, end);

    try {
        return getJdbcTemplate()
                .query(sql.toString(), new Object[]{tenantId, tenantId}, new int[]{Types.INTEGER, Types.INTEGER},
                        itemRowMapper);
    } catch (Exception e) {
        logger.error("failed to get items with rules", e);
        return null;
    }
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:26,代码来源:ItemDAOMysqlImpl.java

示例3: count

import org.easyrec.utils.io.MySQL; //导入方法依赖的package包/类
@Override
public Integer count(Integer tenantId, String description) {
    StringBuilder sql = new StringBuilder().
            append(" SELECT Count(1) FROM ").
            append(DEFAULT_TABLE_NAME).
            append(" WHERE tenantId= ? ");

    Object[] args = {tenantId};
    int[] argTypes = {Types.INTEGER};

    sql = MySQL.addLikeClause(sql, "DESCRIPTION", description);

    try {
        return getJdbcTemplate().queryForInt(sql.toString(), args, argTypes);
    } catch (Exception e) {
        logger.debug("failed to get count", e);
        return 0;
    }
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:20,代码来源:ItemDAOMysqlImpl.java

示例4: getItems

import org.easyrec.utils.io.MySQL; //导入方法依赖的package包/类
@Override
public List<Item> getItems(RemoteTenant remoteTenant, String description, int start, int end) {
    List<Item> items;

    Object[] args = {remoteTenant.getId(), Item.DEFAULT_STRING_ITEM_TYPE};
    int[] argTypes = {Types.INTEGER, Types.VARCHAR};

    StringBuilder sql = new StringBuilder(SQL_GET_ITEMS);
    sql = MySQL.addLikeClause(sql, "DESCRIPTION", description);
    sql = MySQL.addLimitClause(sql, start, end);

    try {
        items = getJdbcTemplate().query(sql.toString(), args, argTypes, itemRowMapper);

        for (final Object item1 : items) {
            Item item = (Item) item1;
            item.setUrl(Text.matchMax(remoteTenant.getUrl(), item.getUrl()));
            item.setImageUrl(Text.matchMax(remoteTenant.getUrl(), item.getImageUrl()));
        }

        return items;
    } catch (Exception e) {
        return null;
    }
}
 
开发者ID:customertimes,项目名称:easyrec-PoC,代码行数:26,代码来源:ItemDAOMysqlImpl.java


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