Program: 35664
Project: 35664
Buggy source:
@Override public Object create(User user,PropertyMap properties){
  orgUnitModel=(OrgUnitModelDTO)properties.get(AdminUtil.ADMIN_ORG_UNIT_MODEL);
  if (orgUnitModel != null && ProjectModelStatus.DRAFT.equals(orgUnitModel.getStatus())) {
    if (orgUnitModel.getId() != -1) {
      update(user,orgUnitModel,properties);
      if (modelToUpdate != null) {
        OrgUnitModelDTO orgUnitDTOUpdated=mapper.map(modelToUpdate,OrgUnitModelDTO.class);
        return orgUnitDTOUpdated;
      }
    }
 else {
      OrgUnitModel oM=createOrgUnitModel(null,properties,user);
      OrgUnitDetails oMDetails=new OrgUnitDetails();
      Layout oMDetailsLayout=new Layout();
      oMDetailsLayout.setColumnsCount(1);
      oMDetailsLayout.setRowsCount(4);
      oMDetails.setLayout(oMDetailsLayout);
      oMDetails.setOrgUnitModel(oM);
      LayoutGroup detailsGroup=new LayoutGroup();
      detailsGroup.setTitle("String_Node_Str");
      detailsGroup.setColumn(0);
      detailsGroup.setRow(0);
      detailsGroup.setParentLayout(oMDetailsLayout);
      int order=0;
      for (      DefaultFlexibleElementType e : DefaultFlexibleElementType.values()) {
        if (!DefaultFlexibleElementType.OWNER.equals(e) && !DefaultFlexibleElementType.START_DATE.equals(e) && !DefaultFlexibleElementType.END_DATE.equals(e)&& !(DefaultFlexibleElementType.BUDGET.equals(e) && Boolean.FALSE.equals(oM.getHasBudget()))) {
          DefaultFlexibleElement defaultElement=new DefaultFlexibleElement();
          defaultElement.setType(e);
          defaultElement.setValidates(false);
          defaultElement.setAmendable(false);
          em.persist(defaultElement);
          LayoutConstraint defaultLayoutConstraint=new LayoutConstraint();
          defaultLayoutConstraint.setParentLayoutGroup(detailsGroup);
          defaultLayoutConstraint.setElement(defaultElement);
          defaultLayoutConstraint.setSortOrder(order++);
          detailsGroup.addConstraint(defaultLayoutConstraint);
        }
      }
      List<LayoutGroup> detailsGroups=new ArrayList<LayoutGroup>();
      detailsGroups.add(detailsGroup);
      oMDetailsLayout.setGroups(detailsGroups);
      OrgUnitBanner oMBanner=new OrgUnitBanner();
      Layout oMBannerLayout=new Layout();
      oMBannerLayout.setColumnsCount(3);
      oMBannerLayout.setRowsCount(2);
      oMBanner.setLayout(oMBannerLayout);
      oMBanner.setOrgUnitModel(oM);
      List<LayoutGroup> bannerGroups=new ArrayList<LayoutGroup>();
      for (int i=0; i < 3; i++) {
        for (int j=0; j < 2; j++) {
          LayoutGroup bannerGroup=new LayoutGroup();
          bannerGroup.setColumn(i);
          bannerGroup.setRow(j);
          bannerGroup.setParentLayout(oMBannerLayout);
          bannerGroups.add(bannerGroup);
        }
      }
      oMBannerLayout.setGroups(bannerGroups);
      oM.setDetails(oMDetails);
      oM.setBanner(oMBanner);
      em.persist(oM);
      return mapper.map(oM,OrgUnitModelDTO.class);
    }
  }
  return null;
}

Fixed version (ground truth):
@Override public Object create(User user,PropertyMap properties){
  orgUnitModel=(OrgUnitModelDTO)properties.get(AdminUtil.ADMIN_ORG_UNIT_MODEL);
  if (orgUnitModel != null && ProjectModelStatus.DRAFT.equals(orgUnitModel.getStatus())) {
    if (orgUnitModel.getId() != -1) {
      update(user,orgUnitModel,properties);
      if (modelToUpdate != null) {
        OrgUnitModelDTO orgUnitDTOUpdated=mapper.map(modelToUpdate,OrgUnitModelDTO.class);
        return orgUnitDTOUpdated;
      }
    }
 else {
      OrgUnitModel oM=createOrgUnitModel(null,properties,user);
      OrgUnitDetails oMDetails=new OrgUnitDetails();
      Layout oMDetailsLayout=new Layout();
      oMDetailsLayout.setColumnsCount(1);
      oMDetailsLayout.setRowsCount(1);
      oMDetails.setLayout(oMDetailsLayout);
      oMDetails.setOrgUnitModel(oM);
      LayoutGroup detailsGroup=new LayoutGroup();
      detailsGroup.setTitle("String_Node_Str");
      detailsGroup.setColumn(0);
      detailsGroup.setRow(0);
      detailsGroup.setParentLayout(oMDetailsLayout);
      int order=0;
      for (      DefaultFlexibleElementType e : DefaultFlexibleElementType.values()) {
        if (!DefaultFlexibleElementType.OWNER.equals(e) && !DefaultFlexibleElementType.START_DATE.equals(e) && !DefaultFlexibleElementType.END_DATE.equals(e)&& !(DefaultFlexibleElementType.BUDGET.equals(e) && Boolean.FALSE.equals(oM.getHasBudget()))) {
          DefaultFlexibleElement defaultElement=new DefaultFlexibleElement();
          defaultElement.setType(e);
          defaultElement.setValidates(false);
          defaultElement.setAmendable(false);
          em.persist(defaultElement);
          LayoutConstraint defaultLayoutConstraint=new LayoutConstraint();
          defaultLayoutConstraint.setParentLayoutGroup(detailsGroup);
          defaultLayoutConstraint.setElement(defaultElement);
          defaultLayoutConstraint.setSortOrder(order++);
          detailsGroup.addConstraint(defaultLayoutConstraint);
        }
      }
      List<LayoutGroup> detailsGroups=new ArrayList<LayoutGroup>();
      detailsGroups.add(detailsGroup);
      oMDetailsLayout.setGroups(detailsGroups);
      OrgUnitBanner oMBanner=new OrgUnitBanner();
      Layout oMBannerLayout=new Layout();
      oMBannerLayout.setColumnsCount(3);
      oMBannerLayout.setRowsCount(2);
      oMBanner.setLayout(oMBannerLayout);
      oMBanner.setOrgUnitModel(oM);
      List<LayoutGroup> bannerGroups=new ArrayList<LayoutGroup>();
      for (int i=0; i < 3; i++) {
        for (int j=0; j < 2; j++) {
          LayoutGroup bannerGroup=new LayoutGroup();
          bannerGroup.setColumn(i);
          bannerGroup.setRow(j);
          bannerGroup.setParentLayout(oMBannerLayout);
          bannerGroups.add(bannerGroup);
        }
      }
      oMBannerLayout.setGroups(bannerGroups);
      oM.setDetails(oMDetails);
      oM.setBanner(oMBanner);
      em.persist(oM);
      return mapper.map(oM,OrgUnitModelDTO.class);
    }
  }
  return null;
}