Package org.nutz.dao

Examples of org.nutz.dao.DaoException


        st.onAfter(conn, null);
      }
    }
    // If any SQLException happend, throw out the SQL string
    catch (SQLException e) {
      throw new DaoException(format"!Nutz SQL Error: '%s'\nPreparedStatement: \n'%s'",
                      st.toString(),
                      st.toPreparedStatement()), e);
    }

  }
View Full Code Here


            catch (SQLException e1) {
              if (log.isErrorEnabled())
                log.error(e1);
            }
          }
        throw new DaoException(e);
      }
    }
    // 无事务
    else {
      Connection conn = null;
      boolean old = false;
      // 开始一个连接
      try {
        conn = dataSource.getConnection();
        // 多条语句运行,将自动提交设为 false
        old = conn.getAutoCommit();
        conn.setAutoCommit(false);
        // 开始循环运行
        callback.invoke(conn);
        // 完成提交
        if (!conn.getAutoCommit())
          conn.commit();
      }
      // 异常回滚
      catch (Exception e) {
        try {
          conn.rollback();
        }
        catch (SQLException e1) {}// TODO 简单记录一下?
        throw new DaoException(e);
      }
      // 保证释放资源
      finally {
        if (null != conn) {
          // 恢复链接自动提交设定
View Full Code Here

        // 检查对象的创建方法
        BornContext<T> bc = Borns.evalByArgTypes(type, ResultSet.class);
        if (null != bc)
            this.bornByRS = bc.getBorning();
        else if (null == bornByDefault)
          throw new DaoException("Need non-arg constructor : " + type);

        // 映射
        this.ones = new LinkFieldSet();
        this.manys = new LinkFieldSet();
        this.manymanys = new LinkFieldSet();
View Full Code Here

    public NutFilePool getPool() {
        if (pool == null) {
            if (log.isWarnEnabled())
                log.warnf("NutDao FilePool create fail!! Blob and Clob Support is DISABLE!!");
            throw new DaoException("NutDao FilePool create fail!! Blob and Clob Support is DISABLE!!");
        }
        return pool;
    }
View Full Code Here

    }

    public <T> T fetch(Class<T> classOfT, long id) {
        Entity<T> en = holder.getEntity(classOfT);
        if (en.getIdField() == null)
            throw new DaoException("Need @Id for " + classOfT);
        Pojo pojo = pojoMaker.makeQuery(en)
                                .append(Pojos.Items.cndId(en, id))
                                .addParamsBy(id)
                                .setAfter(_pojo_fetchEntity);
        _exec(pojo);
View Full Code Here

    public <T> T fetch(Class<T> classOfT, String name) {
        if (name == null)
            throw new IllegalArgumentException("name MUST NOT NULL!");
        Entity<T> en = holder.getEntity(classOfT);
        if (en.getNameField() == null)
            throw new DaoException("Need @Name for " + classOfT);
        Pojo pojo = pojoMaker.makeQuery(en)
                                .append(Pojos.Items.cndName(en, name))
                                .addParamsBy(name)
                                .setAfter(_pojo_fetchEntity);
        _exec(pojo);
View Full Code Here

        }
        // If any SQLException happend, throw out the SQL string
        catch (SQLException e) {
            if (log.isInfoEnabled())
                log.debug("SQLException", e);
            throw new DaoException(format(    "!Nutz SQL Error: '%s'\nPreparedStatement: \n'%s'",
                                            st.toString(),
                                            st.toPreparedStatement()), e);
        }

    }
View Full Code Here

    }

    public static PItem cndId(Entity<?> en, Number id) {
        MappingField mappingField = en.getIdField();
        if (mappingField == null)
            throw new DaoException("expect @Id but NOT found. " + en.getType().getName());
      return cndColumn(mappingField, id);
    }
View Full Code Here

    }

    public static PItem cndName(Entity<?> en, String name) {
        MappingField mappingField = en.getNameField();
            if (mappingField == null)
                throw new DaoException("expect @Name but NOT found. " + en.getType().getName());
      return cndColumn(mappingField, name);
    }
View Full Code Here

            }
            return re;
        }
        catch (SQLException e) {
          if (name != null) {
            throw new DaoException(String.format("Column Name=%s, index=%d", name, i), e);
          }
            throw new DaoException(e);
        }
    }
View Full Code Here

TOP

Related Classes of org.nutz.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.