Package org.eweb4j.orm.dao

Examples of org.eweb4j.orm.dao.DAOException


      List<?> tarList = null;

      try {
        tarList = (List<?>) tarGetter.invoke(t);
      } catch (Exception e) {
        throw new DAOException(tarGetter + " invoke exception ", e);
      }

      if (tarList == null)
        continue;
      for (int i = 0; i < tarList.size(); i++) {
View Full Code Here


      List<?> tarList = null;

      try {
        tarList = (List<?>) tarGetter.invoke(t);
      } catch (Exception e) {
        throw new DAOException(tarGetter + " invoke exception ", e);
      }

      if (tarList == null || tarList.size() == 0) {
        // 当关联对象为空的时候,删除所有关联对象
        // delete from {tarTable} where {column} = {idVal}
        String format = "delete from %s where %s = ? ";
        String sql = String.format(format, tarTable, column);
        DAOFactory.getUpdateDAO(dsName).updateBySQLWithArgs(sql, idVal);
      } else {
        for (int i = 0; i < tarList.size(); i++) {
          Object tarObj = tarList.get(i);
          if (tarObj == null)
            continue;
          // 检查是否该对象真的与主对象有关联且存在数据库
          // select * from {tarTable} where {tarIdColumn} =
          // {tarIdVal} and {column} = {idVal}
          String format = "select * from %s where %s = ? and %s = ? ";

          ReflectUtil tarRu = new ReflectUtil(tarObj);
          String tarIdColumn = ORMConfigBeanUtil
              .getIdColumn(tarClass);
          String tarIdField = ORMConfigBeanUtil.getIdField(tarClass);
          Method tarIdGetter = tarRu.getGetter(tarIdField);

          if (tarIdGetter == null)
            throw new DAOException("can not find tarIdGetter.",
                null);

          Object tarIdValObj = null;

          try {
            tarIdValObj = tarIdGetter.invoke(tarObj);
          } catch (Exception e) {
            throw new DAOException(tarIdGetter
                + " invoke exception ", e);
          }

          if (tarIdValObj == null)
            continue;
View Full Code Here

        continue;
      try {
        tarSetter.invoke(t, tarList);
      } catch (Exception e) {

        throw new DAOException("", e);
      }
    }
  }
View Full Code Here

    // 主类的ID属性名
    this.idField = ORMConfigBeanUtil.getIdField(this.t.getClass());
    this.idColumn = ORMConfigBeanUtil.getIdColumn(this.t.getClass());
    this.idGetter = ru.getGetter(idField);
    if (idGetter == null)
      throw new DAOException("can not find idGetter.", null);

    Object idVal;
    try {
      idVal = idGetter.invoke(this.t);
      this.idVal = idVal == null ? null : String.valueOf(idVal);
    } catch (Exception e) {

      throw new DAOException("", e);
    }
  }
View Full Code Here

          continue;

        Method tarSetter = ru.getSetter(f.getName());
        tarSetter.invoke(t, tarObj);
      } catch (Exception e) {
        throw new DAOException("", e);
      }
    }
  }
View Full Code Here

          String[] sqls = SqlFactory.getUpdateSql(new Object[] { ts[i] }).update();
          ids[i] = JdbcUtil.update(con, sqls[i]);
          // 更新缓存
        }
      } catch (Exception e) {
        throw new DAOException("batchUpdate exception ", e);
      }
    }
    return ids;
  }
View Full Code Here

          String[] sqls = SqlFactory.getUpdateSql(ts).update(fields);
          ids[i] = JdbcUtil.update(con, sqls[i]);
          // 更新缓存
        }
      } catch (Exception e) {
        throw new DAOException("updateByFields exception ", e);
      }
    }
    return ids;
  }
View Full Code Here

              values);
          ids[i] = JdbcUtil.update(con, sqls[i]);
          // 更新缓存
        }
      } catch (Exception e) {
        throw new DAOException("updateByFieldIsValue exception ", e);
      }
    }
    return ids;
  }
View Full Code Here

    Connection con = null;
    try {
      con = ds.getConnection();
      result = JdbcUtil.update(con, sqls);
    } catch (Exception e) {
      throw new DAOException("updateBySQL exception ", e);
    }

    return result;
  }
View Full Code Here

    Connection con = null;
    try {
      con = ds.getConnection();
      result = JdbcUtil.updateWithArgs(con, sqls, args);
    } catch (Exception e) {
      throw new DAOException("updateBySQLWithArgs exception ", e);
    }

    return result;
  }
View Full Code Here

TOP

Related Classes of org.eweb4j.orm.dao.DAOException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.