public Result < List < Data > > readByUser ( AuthzTrans trans , final String user ) { DAOGetter getter = new DAOGetter ( trans , dao ( ) ) { public Result < List < Data > > call ( ) { // If the call is for THIS user, and it exists, get from TRANS, add to TRANS if not. if ( user != null && user . equals ( trans . user ( ) ) ) { Result < List < Data >> transLD = trans . get ( transURSlot , null ) ; if ( transLD == null ) { transLD = dao . readByUser ( trans , user ) ; } return transLD ; } else { return dao . readByUser ( trans , user ) ; } } } ; Result < List < Data > > lurd = get ( trans , user , getter ) ; if ( lurd . isOK ( ) && lurd . isEmpty ( ) ) { return Result . err ( Status . ERR_UserRoleNotFound , "UserRole not found for [%s]" , user ) ; } return lurd ; }
Special Case . User Roles by User are very likely to be called many times in a Transaction to validate May User do ... Pull result and make accessible by the Trans which is always keyed by User .