本文整理汇总了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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}