public boolean save ( ) { filter ( FILTER_BY_SAVE ) ; Config config = _getConfig ( ) ; Table table = _getTable ( ) ; StringBuilder sql = new StringBuilder ( ) ; List < Object > paras = new ArrayList < Object > ( ) ; config . dialect . forModelSave ( table , attrs , sql , paras ) ; // if (paras.size() == 0) return false; // The sql "insert into tableName() values()" works fine, so delete this line // -------- Connection conn = null ; PreparedStatement pst = null ; int result = 0 ; try { conn = config . getConnection ( ) ; if ( config . dialect . isOracle ( ) ) { pst = conn . prepareStatement ( sql . toString ( ) , table . getPrimaryKey ( ) ) ; } else { pst = conn . prepareStatement ( sql . toString ( ) , Statement . RETURN_GENERATED_KEYS ) ; } config . dialect . fillStatement ( pst , paras ) ; result = pst . executeUpdate ( ) ; config . dialect . getModelGeneratedKey ( this , pst , table ) ; _getModifyFlag ( ) . clear ( ) ; return result >= 1 ; } catch ( Exception e ) { throw new ActiveRecordException ( e ) ; } finally { config . close ( pst , conn ) ; } }
Save model .