Program: 166602
Project: 166602
Buggy source:
@Transactional(readOnly=false) public SurveyDefinition surveyDefinition_merge(SurveyDefinition surveyDefinition){
  if (surveyDefinition.getId() == null) {
    surveyDefinition.setDepartment(departmentDAO.findById(surveyDefinition.getDepartment().getId()));
    return surveyDefinitionDAO.merge(surveyDefinition);
  }
 else {
    SurveyDefinition dbSurveyDefinition=surveyDefinitionDAO.findById(surveyDefinition.getId());
    dbSurveyDefinition.setName(surveyDefinition.getName());
    dbSurveyDefinition.setSurveyTheme(surveyDefinition.getSurveyTheme());
    dbSurveyDefinition.setDescription(surveyDefinition.getDescription());
    dbSurveyDefinition.setEmailInvitationTemplate(surveyDefinition.getEmailInvitationTemplate());
    dbSurveyDefinition.setCompletedSurveyTemplate(surveyDefinition.getCompletedSurveyTemplate());
    dbSurveyDefinition.setAutoRemindersDayOfMonth(surveyDefinition.getAutoRemindersDayOfMonth());
    dbSurveyDefinition.setAutoRemindersDays(surveyDefinition.getAutoRemindersDays());
    dbSurveyDefinition.setAutoRemindersFrequency(surveyDefinition.getAutoRemindersFrequency());
    dbSurveyDefinition.setAutoRemindersMonthlyOccurrence(surveyDefinition.getAutoRemindersMonthlyOccurrence());
    dbSurveyDefinition.setAutoRemindersWeeklyOccurrence(surveyDefinition.getAutoRemindersWeeklyOccurrence());
    dbSurveyDefinition.setCompletedSurveyTemplate(surveyDefinition.getCompletedSurveyTemplate());
    dbSurveyDefinition.setSendAutoReminders(surveyDefinition.getSendAutoReminders());
    surveyDefinition.setDepartment(departmentDAO.findById(surveyDefinition.getDepartment().getId()));
    return surveyDefinitionDAO.merge(dbSurveyDefinition);
  }
}

Fixed version (ground truth):
@Transactional(readOnly=false) public SurveyDefinition surveyDefinition_merge(SurveyDefinition surveyDefinition){
  if (surveyDefinition.getId() == null) {
    surveyDefinition.setDepartment(departmentDAO.findById(surveyDefinition.getDepartment().getId()));
    return surveyDefinitionDAO.merge(surveyDefinition);
  }
 else {
    SurveyDefinition dbSurveyDefinition=surveyDefinitionDAO.findById(surveyDefinition.getId());
    dbSurveyDefinition.setName(surveyDefinition.getName());
    dbSurveyDefinition.setSurveyTheme(surveyDefinition.getSurveyTheme());
    dbSurveyDefinition.setDescription(surveyDefinition.getDescription());
    dbSurveyDefinition.setEmailInvitationTemplate(surveyDefinition.getEmailInvitationTemplate());
    dbSurveyDefinition.setCompletedSurveyTemplate(surveyDefinition.getCompletedSurveyTemplate());
    dbSurveyDefinition.setAutoRemindersDayOfMonth(surveyDefinition.getAutoRemindersDayOfMonth());
    dbSurveyDefinition.setAutoRemindersDays(surveyDefinition.getAutoRemindersDays());
    dbSurveyDefinition.setAutoRemindersFrequency(surveyDefinition.getAutoRemindersFrequency());
    dbSurveyDefinition.setAutoRemindersMonthlyOccurrence(surveyDefinition.getAutoRemindersMonthlyOccurrence());
    dbSurveyDefinition.setAutoRemindersWeeklyOccurrence(surveyDefinition.getAutoRemindersWeeklyOccurrence());
    dbSurveyDefinition.setCompletedSurveyTemplate(surveyDefinition.getCompletedSurveyTemplate());
    dbSurveyDefinition.setSendAutoReminders(surveyDefinition.getSendAutoReminders());
    dbSurveyDefinition.setAllowMultipleSubmissions(surveyDefinition.getAllowMultipleSubmissions());
    dbSurveyDefinition.setIsPublic(surveyDefinition.getIsPublic());
    surveyDefinition.setDepartment(departmentDAO.findById(surveyDefinition.getDepartment().getId()));
    return surveyDefinitionDAO.merge(dbSurveyDefinition);
  }
}