Package com.jfinal.plugin.activerecord

Examples of com.jfinal.plugin.activerecord.ActiveRecordException


            callbackListener.beforeDelete(this);
        }
        boolean result = false;
        if (pseudoDelete()) {
            if (!tableInfo.hasColumnLabel(deleteColumnLabel)) {
                throw new ActiveRecordException("The deleteColumnLabel (" + deleteColumnLabel + ") is not exist");
            }
            this.set(deleteColumnLabel, 1);
            result = this.update();
        } else {
            result = super.delete();
View Full Code Here


            callbackListener.beforeDelete(this);
        }
        boolean result = false;
        if (pseudoDelete()) {
            if (!tableInfo.hasColumnLabel(deleteColumnLabel)) {
                throw new ActiveRecordException("The deleteColumnLabel (" + deleteColumnLabel + ") is not exist");
            }
            String pKey = tableInfo.getPrimaryKey();
            if (id == null)
                throw new ActiveRecordException("You can't update model without Primary Key.");
            String sql = "update "+tableInfo.getName()+" set "+deleteColumnLabel+" = 1 where "+pKey+" = ?";
            result = Db.update(sql,id)>=1;
        } else {
            result = super.deleteById(id);
        }
View Full Code Here

        Preconditions.checkArgument(values.size() == columns.size(), "column size != values size");
        String sql="";
        Table tableInfo = TableMapping.me().getTable(clazz);
        if (pseudoDelete()) {
            if (!tableInfo.hasColumnLabel(deleteColumnLabel)) {
                throw new ActiveRecordException("The deleteColumnLabel (" + deleteColumnLabel + ") is not exist");
            }
            String pKey = tableInfo.getPrimaryKey();
            sql+= "update "+tableInfo.getName()+" set "+deleteColumnLabel+" = 1";
        }else{
            sql+= "delete from " + tableInfo.getName() ;
View Full Code Here

        String primaryKey = TableMapping.me().getTable(clazz).getPrimaryKey();
        try {
            return childModel.newInstance().find("select * from " + childTableName + " where " + foreignKey + "= ?",
                    get(primaryKey));
        } catch (Exception e) {
            throw new ActiveRecordException(e.getMessage(), e);
        }
    }
View Full Code Here

        String primaryKey = TableMapping.me().getTable(clazz).getPrimaryKey();
        try {
            return (M) parentModel.newInstance().findFirst(
                    "select * from " + parentTableName + " where " + foreignKey + "= ?", get(primaryKey));
        } catch (Exception e) {
            throw new ActiveRecordException(e.getMessage(), e);
        }
    }
View Full Code Here

 
  /**
   * SELECT * FROM subject t1 WHERE (SELECT count(*) FROM subject t2 WHERE t2.id < t1.id AND t2.key = '123') > = 10 AND (SELECT count(*) FROM subject t2 WHERE t2.id < t1.id AND t2.key = '123') < 20 AND t1.key = '123'
   */
  public void forPaginate(StringBuilder sql, int pageNumber, int pageSize, String select, String sqlExceptSelect) {
    throw new ActiveRecordException("Your should not invoke this method because takeOverDbPaginate(...) will take over it.");
  }
View Full Code Here

      String paraKey = e.getKey();
      if (paraKey.startsWith(modelNameAndDot)) {
        String paraName = paraKey.substring(modelNameAndDot.length());
        Class colType = table.getColumnType(paraName);
        if (colType == null)
          throw new ActiveRecordException("The model attribute " + paraKey + " is not exists.");
        String[] paraValue = e.getValue();
        try {
          // Object value = Converter.convert(colType, paraValue != null ? paraValue[0] : null);
          Object value = paraValue[0] != null ? TypeConverter.convert(colType, paraValue[0]) : null;
          model.set(paraName, value);
View Full Code Here

        if (conn.getTransactionIsolation() < getTransactionLevel(config))
          conn.setTransactionIsolation(getTransactionLevel(config));
        ai.invoke();
        return ;
      } catch (SQLException e) {
        throw new ActiveRecordException(e);
      }
    }
   
    Boolean autoCommit = null;
    try {
      conn = config.getConnection();
      autoCommit = conn.getAutoCommit();
      config.setThreadLocalConnection(conn);
      conn.setTransactionIsolation(getTransactionLevel(config))// conn.setTransactionIsolation(transactionLevel);
      conn.setAutoCommit(false);
      ai.invoke();
      conn.commit();
    } catch (NestedTransactionHelpException e) {
      if (conn != null) try {conn.rollback();} catch (Exception e1) {e1.printStackTrace();}
    } catch (Exception e) {
      if (conn != null) try {conn.rollback();} catch (Exception e1) {e1.printStackTrace();}
      throw new ActiveRecordException(e);
    }
    finally {
      try {
        if (conn != null) {
          if (autoCommit != null)
View Full Code Here

      String paraKey = e.getKey();
      if (paraKey.startsWith(modelNameAndDot)) {
        String paraName = paraKey.substring(modelNameAndDot.length());
        Class colType = tableInfo.getColType(paraName);
        if (colType == null)
          throw new ActiveRecordException("The model attribute " + paraKey + " is not exists.");
        String[] paraValue = e.getValue();
        try {
          // Object value = Converter.convert(colType, paraValue != null ? paraValue[0] : null);
          Object value = paraValue[0] != null ? TypeConverter.convert(colType, paraValue[0]) : null;
          model.set(paraName, value);
View Full Code Here

    return DbKit.getTransactionLevel();
  }
 
  public void intercept(ActionInvocation invocation) {
    if (DbKit.isExistsThreadLocalConnection())
      throw new ActiveRecordException("Nested transaction can not be supported. You can't execute transaction inside another transaction.");
   
    Connection conn = null;
    Boolean autoCommit = null;
    try {
      conn = DbKit.getDataSource().getConnection();
      autoCommit = conn.getAutoCommit();
      DbKit.setThreadLocalConnection(conn);
      conn.setTransactionIsolation(getTransactionLevel())// conn.setTransactionIsolation(transactionLevel);
      conn.setAutoCommit(false);
      invocation.invoke();
      conn.commit();
    } catch (Exception e) {
      if (conn != null)
        try {conn.rollback();} catch (Exception e1) {e1.printStackTrace();}
      throw new ActiveRecordException(e);
    }
    finally {
      try {
        if (conn != null) {
          if (autoCommit != null)
View Full Code Here

TOP

Related Classes of com.jfinal.plugin.activerecord.ActiveRecordException

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.