Buggy code:
public class BillDAO extends SuperDAO { private static final Logger logger = LogManager . getLogger ( BillDAO . class . getName ( ) ) ; private NamedParameterJdbcTemplate jdbcTemplate = null ; private SimpleJdbcTemplate sjdbcTemplate = null ; private static final String ALL_BILLS_QUERY = "select<seq2seq4repair_space>b.id,bm.id<seq2seq4repair_space>master_bill_id,c.name<seq2seq4repair_space>company,b.amount,u.firstName<seq2seq4repair_space>addedby,bf.description<seq2seq4repair_space>frequency,<seq2seq4repair_space>b.auto_generated," + ( ( ( "bm.payment_mode,<seq2seq4repair_space>bm.location,<seq2seq4repair_space>bm.description<seq2seq4repair_space>bill_desc,<seq2seq4repair_space>b.paid,<seq2seq4repair_space>b.deleted,<seq2seq4repair_space>bm.due_day,<seq2seq4repair_space>b.due_date,<seq2seq4repair_space>b.creation_date,<seq2seq4repair_space>bm.auto_recur<seq2seq4repair_space>" + "from<seq2seq4repair_space>btrack.bill_master<seq2seq4repair_space>bm,<seq2seq4repair_space>bill<seq2seq4repair_space>b,<seq2seq4repair_space>bill_freq<seq2seq4repair_space>bf,<seq2seq4repair_space>users<seq2seq4repair_space>u,<seq2seq4repair_space>company<seq2seq4repair_space>c<seq2seq4repair_space>" ) + "where<seq2seq4repair_space>b.master_bill_id<seq2seq4repair_space>=<seq2seq4repair_space>bm.id<seq2seq4repair_space>and<seq2seq4repair_space>b.freq_id<seq2seq4repair_space>=<seq2seq4repair_space>bf.id<seq2seq4repair_space>and<seq2seq4repair_space>bm.user_id<seq2seq4repair_space>=<seq2seq4repair_space>u.id<seq2seq4repair_space>and<seq2seq4repair_space>b.deleted<seq2seq4repair_space>=<seq2seq4repair_space>0<seq2seq4repair_space>" ) + "and<seq2seq4repair_space>bm.company_id<seq2seq4repair_space>=<seq2seq4repair_space>c.id<seq2seq4repair_space>order<seq2seq4repair_space>by<seq2seq4repair_space>b.id<seq2seq4repair_space>desc" ) ; private static final String NEW_BILL_MASTER_QUERY = "insert<seq2seq4repair_space>into<seq2seq4repair_space>bill_master(company_id,location,freq_id,amount," + ( ( "payment_mode,user_id,description,due_day,due_date,auto_recur)<seq2seq4repair_space>values<seq2seq4repair_space>(" + ":company_id,:location,(select<seq2seq4repair_space>id<seq2seq4repair_space>from<seq2seq4repair_space>btrack.bill_freq<seq2seq4repair_space>where<seq2seq4repair_space>code=:freq_type),:amount,:payment_mode,:user_id," ) + ":desc,:due_day,:due_date,:auto_recur)" ) ; private static final String NEW_BILL_INSTANCE_QUERY = "insert<seq2seq4repair_space>into<seq2seq4repair_space>bill(master_bill_id,amount,description,payment_mode,freq_id,due_date,paid,deleted,auto_generated)<seq2seq4repair_space>values<seq2seq4repair_space>(" + ":master_bill_id,:amount,:description,:payment_mode,(select<seq2seq4repair_space>id<seq2seq4repair_space>from<seq2seq4repair_space>btrack.bill_freq<seq2seq4repair_space>where<seq2seq4repair_space>code=:freq_type),:due_date,:paid,0,:auto_generated)" ; private static final String LAST_ID_QUERY = "select<seq2seq4repair_space>last_insert_id()" ; private static final String VIEW_BILL_QUERY = "select<seq2seq4repair_space>b.id,bm.id<seq2seq4repair_space>master_bill_id,c.name<seq2seq4repair_space>company,b.amount,u.firstName<seq2seq4repair_space>addedby,<seq2seq4repair_space>bf.description<seq2seq4repair_space>frequency,<seq2seq4repair_space>b.auto_generated," + ( ( "b.payment_mode,<seq2seq4repair_space>bm.location,<seq2seq4repair_space>b.description<seq2seq4repair_space>bill_desc,<seq2seq4repair_space>b.paid,<seq2seq4repair_space>b.deleted,<seq2seq4repair_space>bm.due_day,<seq2seq4repair_space>b.due_date,<seq2seq4repair_space>b.creation_date,<seq2seq4repair_space>bm.auto_recur<seq2seq4repair_space>" + "from<seq2seq4repair_space>btrack.bill_master<seq2seq4repair_space>bm,<seq2seq4repair_space>bill<seq2seq4repair_space>b,<seq2seq4repair_space>bill_freq<seq2seq4repair_space>bf,<seq2seq4repair_space>users<seq2seq4repair_space>u,<seq2seq4repair_space>company<seq2seq4repair_space>c<seq2seq4repair_space>where<seq2seq4repair_space>b.master_bill_id<seq2seq4repair_space>=<seq2seq4repair_space>bm.id<seq2seq4repair_space>and<seq2seq4repair_space>" ) + "b.freq_id<seq2seq4repair_space>=<seq2seq4repair_space>bf.id<seq2seq4repair_space>and<seq2seq4repair_space>bm.user_id<seq2seq4repair_space>=<seq2seq4repair_space>u.id<seq2seq4repair_space>and<seq2seq4repair_space>bm.company_id<seq2seq4repair_space>=<seq2seq4repair_space>c.id<seq2seq4repair_space>and<seq2seq4repair_space>b.id=:bill_id" ) ; private static final String EDIT_BILL_QUERY = "select<seq2seq4repair_space>b.id,bm.id<seq2seq4repair_space>master_bill_id,c.id<seq2seq4repair_space>company,b.amount,u.firstName<seq2seq4repair_space>addedby,<seq2seq4repair_space>bf.code<seq2seq4repair_space>frequency,<seq2seq4repair_space>b.auto_generated," + ( ( "b.payment_mode,<seq2seq4repair_space>bm.location,<seq2seq4repair_space>b.description<seq2seq4repair_space>bill_desc,<seq2seq4repair_space>b.paid,<seq2seq4repair_space>b.deleted,<seq2seq4repair_space>bm.due_day,<seq2seq4repair_space>b.due_date,<seq2seq4repair_space>b.creation_date,<seq2seq4repair_space>bm.auto_recur<seq2seq4repair_space>" + "from<seq2seq4repair_space>btrack.bill_master<seq2seq4repair_space>bm,<seq2seq4repair_space>bill<seq2seq4repair_space>b,<seq2seq4repair_space>bill_freq<seq2seq4repair_space>bf,<seq2seq4repair_space>users<seq2seq4repair_space>u,<seq2seq4repair_space>company<seq2seq4repair_space>c<seq2seq4repair_space>where<seq2seq4repair_space>b.master_bill_id<seq2seq4repair_space>=<seq2seq4repair_space>bm.id<seq2seq4repair_space>and<seq2seq4repair_space>" ) + "b.freq_id<seq2seq4repair_space>=<seq2seq4repair_space>bf.id<seq2seq4repair_space>and<seq2seq4repair_space>bm.user_id<seq2seq4repair_space>=<seq2seq4repair_space>u.id<seq2seq4repair_space>and<seq2seq4repair_space>bm.company_id<seq2seq4repair_space>=<seq2seq4repair_space>c.id<seq2seq4repair_space>and<seq2seq4repair_space>b.id=:bill_id" ) ; private static final String ALL_ACTIVE_RECURRING_BILLS_QUERY = "select<seq2seq4repair_space>bm.id,<seq2seq4repair_space>bf.code,<seq2seq4repair_space>bm.amount,<seq2seq4repair_space>bm.description,<seq2seq4repair_space>bm.location,<seq2seq4repair_space>bm.payment_mode,<seq2seq4repair_space>bm.due_date,<seq2seq4repair_space>bm.due_day<seq2seq4repair_space>from<seq2seq4repair_space>bill_master<seq2seq4repair_space>bm," + "<seq2seq4repair_space>bill_freq<seq2seq4repair_space>bf<seq2seq4repair_space>where<seq2seq4repair_space>bm.freq_id<seq2seq4repair_space>=<seq2seq4repair_space>bf.id<seq2seq4repair_space>and<seq2seq4repair_space>bm.auto_recur<seq2seq4repair_space>=<seq2seq4repair_space>1" ; private static final String ALL_BILLS_FOR_MASTER_BILL_QUERY = "select<seq2seq4repair_space>b.id,bm.id<seq2seq4repair_space>master_bill_id,c.name<seq2seq4repair_space>company,b.amount,u.firstName<seq2seq4repair_space>addedby,bf.code<seq2seq4repair_space>frequency,<seq2seq4repair_space>b.auto_generated," + ( ( ( "b.payment_mode,<seq2seq4repair_space>bm.location,<seq2seq4repair_space>b.description<seq2seq4repair_space>bill_desc,<seq2seq4repair_space>b.paid,<seq2seq4repair_space>b.deleted,<seq2seq4repair_space>bm.due_day,<seq2seq4repair_space>b.due_date,<seq2seq4repair_space>b.creation_date,<seq2seq4repair_space>bm.auto_recur<seq2seq4repair_space>" + "from<seq2seq4repair_space>btrack.bill_master<seq2seq4repair_space>bm,<seq2seq4repair_space>bill<seq2seq4repair_space>b,<seq2seq4repair_space>bill_freq<seq2seq4repair_space>bf,<seq2seq4repair_space>users<seq2seq4repair_space>u,<seq2seq4repair_space>company<seq2seq4repair_space>c<seq2seq4repair_space>" ) + "where<seq2seq4repair_space>b.master_bill_id<seq2seq4repair_space>=<seq2seq4repair_space>bm.id<seq2seq4repair_space>and<seq2seq4repair_space>b.freq_id<seq2seq4repair_space>=<seq2seq4repair_space>bf.id<seq2seq4repair_space>and<seq2seq4repair_space>bm.user_id<seq2seq4repair_space>=<seq2seq4repair_space>u.id<seq2seq4repair_space>and<seq2seq4repair_space>b.deleted<seq2seq4repair_space>=<seq2seq4repair_space>0<seq2seq4repair_space>" ) + "and<seq2seq4repair_space>bm.company_id<seq2seq4repair_space>=<seq2seq4repair_space>c.id<seq2seq4repair_space>and<seq2seq4repair_space>bm.id<seq2seq4repair_space>=<seq2seq4repair_space>:master_bill_id<seq2seq4repair_space>order<seq2seq4repair_space>by<seq2seq4repair_space>b.due_date<seq2seq4repair_space>desc" ) ; public BillDAO ( NamedParameterJdbcTemplate template , SimpleJdbcTemplate stemplate ) { } public List < BillBO > getAllBills ( ) { } public BillBO getBillInfo ( int billId ) throws Exception { } public BillBO getBillInfoForEdit ( int billId ) throws Exception { } public List < BillBO > getAllActiveRecurringBills ( ) throws Exception { } public List < BillBO > getBillListForMasterBill ( int masterBillId ) throws Exception { } @ Transactional ( rollbackFor = { Exception . class } ) public int addAutoGenBill ( BillBO bill ) throws Exception { } @ Transactional ( rollbackFor = { Exception . class , DataAccessException . class } ) public int addBill ( int companyId , String location , char freqType , Double amount , String paymentMode , int userId , String desc , int dueDay , Date dueDate , int autoRecur , int paid ) throws Exception { } static class AllRecurringBillsExtractor implements ResultSetExtractor < List < BillBO > > { public List < BillBO > extractData ( ResultSet rs ) throws SQLException , DataAccessException { } } static class AllBillsExtractor implements ResultSetExtractor < List < BillBO > > { public List < BillBO > extractData ( ResultSet rs ) throws SQLException , DataAccessException { } } static class BillInfoExtractor implements ResultSetExtractor < BillBO > { public BillBO extractData ( ResultSet rs ) throws SQLException , DataAccessException { } } static class EditBillInfoExtractor implements ResultSetExtractor < BillBO > { public BillBO extractData ( ResultSet rs ) throws SQLException , DataAccessException { } } private static BillBO populateBillBOFromResultSet ( ResultSet rs ) throws SQLException { BillBO b = new BillBO ( ) ; b . setId ( getInteger ( rs , "id" ) ) ; b . setMasterId ( getInteger ( rs , "master_bill_id" ) ) ; b . setCompany ( getString ( rs , "company" ) ) ; b . setAmount ( getDouble ( rs , "amount" ) ) ; b . setLocation ( getString ( rs , "location" ) ) ; b . setUser ( getString ( rs , "addedby" ) ) ; b . setFrequency ( getString ( rs , "frequency" ) ) ; b . setDescription ( getString ( rs , "bill_desc" ) ) ; b . setPaymentMode ( getString ( rs , "payment_mode" ) ) ; b . setDueDay ( getInteger ( rs , "due_day" ) ) ; b . setDueDate ( getDate ( rs , "due_date" ) ) ; final int billStatus = getInteger ( rs , "paid" ) ; if ( billStatus != 1 ) { b . setStatus ( "Unpaid" ) ; } else { b . setStatus ( "Paid" ) ; } final int billDeleted = getInteger ( rs , "deleted" ) ; if ( billDeleted != 1 ) { b . setDeleted ( false ) ; } else { b . setDeleted ( true ) ; } final int recurring = getInteger ( rs , "auto_recur" ) ; if ( recurring != 1 ) { b . setRecurring ( false ) ; } else { b . setRecurring ( true ) ; } final int autogen = getInteger ( rs , "auto_generated" ) ; <START_BUG> if ( recurring != 1 ) { <END_BUG> b . setAutoGenerated ( false ) ; } else { b . setAutoGenerated ( true ) ; } b . setCreationDate ( getTimestamp ( rs , "creation_date" ) ) ; return b ; } }

Fix:
if ( autogen != 1 ) {