Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 public List BatchGetByAttr(String attrName, Object attrValue) {
   String sql = "SELECT * FROM " + TableName() + " WHERE " + attrName + " = ?";
   return QueryHelper.query(getClass(), sql, attrValue);
 }