protected List<? extends POJO> BatchGet(List<Long> ids) { if (ids == null || ids.size() == 0) return null; StringBuilder sql = new StringBuilder("SELECT * FROM " + TableName() + " WHERE id IN ("); for (int i = 1; i <= ids.size(); i++) { sql.append('?'); if (i < ids.size()) sql.append(','); } sql.append(')'); List<? extends POJO> beans = QueryHelper.query(getClass(), sql.toString(), ids.toArray(new Object[ids.size()])); if (IsObjectCachedByID()) { for (Object bean : beans) { CacheManager.set(CacheRegion(), ((POJO) bean).getId(), (Serializable) bean); } } return beans; }
public List BatchGetByAttr(String attrName, Object attrValue) { String sql = "SELECT * FROM " + TableName() + " WHERE " + attrName + " = ?"; return QueryHelper.query(getClass(), sql, attrValue); }