Buggy code:
public class TrainingManager { private static final Logger logger = Logger . getLogger ( TrainingManager . class . getName ( ) ) ; UserManager userManager = UserManager . getInstance ( ) ; TrainingCache cache = TrainingCache . getInstance ( ) ; TrainingDAO dao = TrainingDAO . getInstance ( ) ; private static TrainingManager man ; public static TrainingManager getInstance ( ) { } public void addExercise ( UserOpenid user , Exercise model , long workoutId ) throws ConnectionException { } public boolean removeExercise ( UserOpenid user , Exercise model , long workoutId ) throws ConnectionException { } public List < Workout > getWorkouts ( UserOpenid user , Date date , String uid ) throws ConnectionException { } public List < Workout > getWorkouts ( UserOpenid user , Date dateStart , Date dateEnd , String uid ) throws ConnectionException { } public List < Workout > getWorkouts ( UserOpenid user , int offset , String uid ) throws ConnectionException { } public List < Routine > getRoutines ( UserOpenid user , int offset , String uid ) throws ConnectionException { } public List < Workout > getMostPopularWorkouts ( UserOpenid user , int offset ) throws ConnectionException { } public List < Routine > getMostPopularRoutines ( UserOpenid user , int offset ) throws ConnectionException { } public List < Workout > getWorkouts ( UserOpenid user , Routine routine , String uid ) throws ConnectionException { } private Workout _getWorkout ( Long key ) throws Exception { } private Routine _getRoutine ( Long routineId ) throws Exception { } private ExerciseName _getExerciseName ( Long key ) throws Exception { } private List < ExerciseName > _getExerciseNames ( ) throws Exception { } private void _updateWorkout ( Workout workout ) throws Exception { } public boolean removeWorkouts ( UserOpenid user , List < Workout > models ) throws ConnectionException { } @ SuppressWarnings ( "deprecation" ) public List < Workout > addWorkouts ( UserOpenid user , List < Workout > models ) throws ConnectionException { } @ SuppressWarnings ( "deprecation" ) public List < Routine > addRoutines ( UserOpenid user , List < Routine > models ) throws ConnectionException { } public List < ExerciseName > searchExerciseNames ( UserOpenid user , String query , int limit ) throws ConnectionException { } public List < ExerciseName > addExerciseName ( UserOpenid user , List < ExerciseName > names ) throws ConnectionException { } public List < Workout > searchWorkouts ( UserOpenid user , String query , int index ) throws ConnectionException { } public List < Routine > searchRoutines ( UserOpenid user , String query , int index ) throws ConnectionException { } public void updateWorkout ( UserOpenid user , Workout model ) throws ConnectionException { if ( TrainingManager . logger . isLoggable ( Level . FINE ) ) { TrainingManager . logger . log ( Level . FINE , ( "Updating<seq2seq4repair_space>workout:<seq2seq4repair_space>" + model ) ) ; } try { <START_BUG> Workout workout = dao . getWorkout ( model . getId ( ) ) ; <END_BUG> userManager . checkPermission ( WRITE_TRAINING , user . getUid ( ) , workout . getUid ( ) ) ; Date dOld = workout . getDate ( ) ; workout . update ( model , false ) ; dao . updateWorkout ( workout ) ; model . update ( workout , true ) ; cache . setWorkouts ( workout . getUid ( ) , workout . getDate ( ) , null ) ; if ( ! ( dOld . equals ( workout . getDate ( ) ) ) ) { cache . setWorkouts ( workout . getUid ( ) , dOld , null ) ; } cache . removeWorkout ( workout . getId ( ) ) ; } catch ( Exception e ) { TrainingManager . logger . log ( Level . SEVERE , "Error<seq2seq4repair_space>updating<seq2seq4repair_space>workout" , e ) ; throw new ConnectionException ( "Error<seq2seq4repair_space>updating<seq2seq4repair_space>workout" , e ) ; } } public void updateRoutine ( UserOpenid user , Routine model ) throws ConnectionException { } public Workout getWorkout ( UserOpenid user , long id ) throws ConnectionException { } public Routine getRoutine ( UserOpenid user , long id ) throws ConnectionException { } public boolean updateExerciseOrder ( UserOpenid user , Long workoutId , Long [ ] ids ) throws ConnectionException { } public void incrementWorkoutCount ( long workoutId ) throws ConnectionException { } public void incrementRoutineCount ( long routineId ) throws ConnectionException { } }

Fix:
Workout workout = _getWorkout ( model . getId ( ) ) ;