question: @ Override public MBHeader findLastMBPageNoForLineItem ( final WorkOrderActivity workOrderActivity , final Long mbHeaderId ) { logger . info ( "-------------------------Inside findLastMBPageNoForLineItem--------------" ) ; String query = "select distinct mbh from MBHeader mbh join mbh.mbDetails as mbDetail " ; Object [ ] params ; final List < Object > paramList = new ArrayList < Object > ( ) ; query = query + " where mbDetail.workOrderActivity.id = ? " + " and mbh.id != ? and mbh.egwStatus.code=? " + " and mbh.modifiedDate < (select modifiedDate from MBHeader where id = ? )" + " order by mbh.modifiedDate desc" ; paramList . add ( workOrderActivity . getId ( ) ) ; paramList . add ( mbHeaderId ) ; paramList . add ( WorksConstants . APPROVED ) ; paramList . add ( mbHeaderId ) ; params = new Object [ paramList . size ( ) ] ; params = paramList . toArray ( params ) ; final List < MBHeader > mbHeaderList = genericService . findAllBy ( query , params ) ; MBHeader result = null ; if ( mbHeaderList != null && ! mbHeaderList . isEmpty ( ) ) result = mbHeaderList . get ( 0 ) ; return result ; }
target:  This method will return toPageNo for a line item from the last mb entry.