public static void generateLogForModifiers ( final SQLiteModelMethod method , MethodSpec . Builder methodBuilder ) { JQLChecker jqlChecker = JQLChecker . getInstance ( ) ; final One < Boolean > usedInWhere = new One < Boolean > ( false ) ; methodBuilder . addCode ( "\n// display log\n" ) ; String sqlForLog = jqlChecker . replace ( method , method . jql , new JQLReplacerListenerImpl ( method ) { @ Override public String onColumnNameToUpdate ( String columnName ) { // only entity's columns return currentEntity . findPropertyByName ( columnName ) . columnName ; } @ Override public String onColumnName ( String columnName ) { // return entity.findByName(columnName).columnName; return currentSchema . findColumnNameByPropertyName ( method , columnName ) ; } @ Override public String onBindParameter ( String bindParameterName , boolean inStatement ) { if ( usedInWhere . value0 ) { return "?" ; } else { String paramName = bindParameterName ; if ( paramName . contains ( "." ) ) { String [ ] a = paramName . split ( "\\." ) ; if ( a . length == 2 ) { paramName = a [ 1 ] ; } } SQLProperty property = currentEntity . findPropertyByName ( paramName ) ; AssertKripton . assertTrueOrUnknownPropertyInJQLException ( property != null , method , bindParameterName ) ; return ":" + property . columnName ; } } @ Override public void onWhereStatementBegin ( Where_stmtContext ctx ) { usedInWhere . value0 = true ; } @ Override public void onWhereStatementEnd ( Where_stmtContext ctx ) { usedInWhere . value0 = false ; } } ) ; if ( method . jql . dynamicReplace . containsKey ( JQLDynamicStatementType . DYNAMIC_WHERE ) ) { methodBuilder . addStatement ( "$T.info($S, $L)" , Logger . class , sqlForLog . replace ( method . jql . dynamicReplace . get ( JQLDynamicStatementType . DYNAMIC_WHERE ) , "%s" ) , "StringUtils.ifNotEmptyAppend(_sqlDynamicWhere,\" AND \")" ) ; } else { methodBuilder . addStatement ( "$T.info($S)" , Logger . class , sqlForLog ) ; } }
generate sql log .