static void generateModifyQueryCommonPart ( SQLiteModelMethod method , TypeSpec . Builder classBuilder , MethodSpec . Builder methodBuilder ) { boolean updateMode = ( method . jql . operationType == JQLType . UPDATE ) ; SqlModifyBuilder . generateInitForDynamicWhereVariables ( method , methodBuilder , method . dynamicWhereParameterName , method . dynamicWhereArgsParameterName ) ; if ( method . jql . hasDynamicParts ( ) || method . jql . containsSelectOperation ) { // query builder if ( method . jql . isWhereConditions ( ) ) { methodBuilder . addStatement ( "$T _sqlBuilder=sqlBuilder()" , StringBuilder . class ) ; } // generate where condition SqlBuilderHelper . generateWhereCondition ( methodBuilder , method , true ) ; // generate SQL SqlModifyBuilder . generateSQL ( method , methodBuilder ) ; } if ( method . isLogEnabled ( ) ) { // generate log section methodBuilder . addComment ( "log section BEGIN" ) ; methodBuilder . beginControlFlow ( "if (_context.isLogEnabled())" ) ; SqlModifyBuilder . generateLogForModifiers ( method , methodBuilder ) ; if ( method . jql . operationType == JQLType . UPDATE && method . isLogEnabled ( ) ) { // generate log for content values SqlBuilderHelper . generateLogForContentValues ( method , methodBuilder ) ; } SqlBuilderHelper . generateLogForWhereParameters ( method , methodBuilder ) ; methodBuilder . endControlFlow ( ) ; methodBuilder . addComment ( "log section END" ) ; } if ( method . jql . hasDynamicParts ( ) || method . jql . containsSelectOperation ) { // does not memorize compiled statement, it can vary every time // generate SQL for insert methodBuilder . addStatement ( "int result = $T.updateDelete(_context, _sql, _contentValues)" , KriptonDatabaseWrapper . class ) ; } else { String psName = method . buildPreparedStatementName ( ) ; methodBuilder . addStatement ( "int result = $T.updateDelete($L, _contentValues)" , KriptonDatabaseWrapper . class , psName ) ; } if ( method . getParent ( ) . getParent ( ) . generateRx ) { if ( updateMode ) { GenericSQLHelper . generateSubjectNext ( method . getEntity ( ) , methodBuilder , SubjectType . UPDATE , "result" ) ; } else { GenericSQLHelper . generateSubjectNext ( method . getEntity ( ) , methodBuilder , SubjectType . DELETE , "result" ) ; } } }
Generate modify query common part .