示例#1
0
文件: Daos.java 项目: GaoHuijian/nutz
  public Object invoke(Object proxy, final Method method, final Object[] args) throws Throwable {

    final Molecule<Object> m =
        new Molecule<Object>() {
          public void run() {
            try {
              setObj(method.invoke(dao, args));
            } catch (IllegalArgumentException e) {
              throw Lang.wrapThrow(e);
            } catch (IllegalAccessException e) {
              throw Lang.wrapThrow(e);
            } catch (InvocationTargetException e) {
              throw Lang.wrapThrow(e.getTargetException());
            }
          }
        };
    if (filter != null && tableName != null) {
      TableName.run(
          tableName,
          new Runnable() {
            public void run() {
              filter.run(m);
            }
          });
      return m.getObj();
    }
    if (filter != null) filter.run(m);
    else TableName.run(tableName, m);
    return m.getObj();
  }
示例#2
0
文件: NutDao.java 项目: JRed1989/nutz
 public int updateIgnoreNull(final Object obj) {
   EntityOperator opt = _optBy(obj);
   if (null == opt) return 0;
   opt.addUpdateForIgnoreNull(opt.entity, obj, FieldFilter.get(opt.entity.getType()));
   opt.exec();
   return opt.getUpdateCount();
 }
示例#3
0
 /**
  * Test表改
  *
  * @param test
  */
 public void update(final Test test) {
   FieldFilter.create(Test.class, true)
       .run(
           new Atom() {
             public void run() {
               dao().update(test);
             }
           });
 }
示例#4
0
文件: NutDao.java 项目: JRed1989/nutz
 public <T> T insert(final T obj, FieldFilter filter) {
   if (filter == null) return insert(obj);
   filter.run(
       new Atom() {
         public void run() {
           insert(obj);
         }
       });
   return obj;
 }
示例#5
0
文件: NutDao.java 项目: JRed1989/nutz
  public int update(final Object obj, String regex) {
    Object first = Lang.first(obj);
    if (null == first) return 0;

    if (Strings.isBlank(regex)) return update(obj);

    Molecule<Integer> m =
        new Molecule<Integer>() {
          public void run() {
            setObj(update(obj));
          }
        };
    FieldFilter.create(first.getClass(), regex).run(m);
    return m.getObj();
  }