Program: 45107
Project: 45107
Buggy source:
private Form<?> createForm(String form,final String button,final BuildingType type){
  Form<?> newForm=new Form<Object>(form);
  final Building building=buildings.get(type);
  AjaxButton newButton=new AjaxButton(button){
    @Override protected void onSubmit(    AjaxRequestTarget target,    Form<?> form){
      Building building=buildings.get(type);
      if (building != null) {
        Integer newLevel=building.getLevel() + 1;
        building.setLevel(newLevel);
        buildingsDao.beginTransaction();
        buildingsDao.update(building);
        mapUserDao.update(baseutils.reduceRessources(mapUser,500));
        buildingsDao.commitTransaction();
        updateBildingCounter(building,this);
        info("String_Node_Str");
      }
 else {
        building=new Building();
        building.setLevel(1);
        building.setType(type);
        building.setUpgrading(false);
        building.setSquare(square);
        square.getBuildings().add(building);
        mapUser.getSquares().add(square);
        baseutils.reduceRessources(mapUser,1500);
        buildingsDao.beginTransaction();
        buildingsDao.insert(building);
        mapUserDao.update(mapUser);
        buildingsDao.commitTransaction();
        updateBildingCounter(building,this);
        buildings.put(type,building);
        info("String_Node_Str");
      }
      target.add(buildWood);
      target.add(buildClay);
      target.add(buildStable);
      target.add(buildBarracks);
      target.add(buildUpgrades);
      target.add(buildDestruction);
      target.add(buildGrain);
      target.add(buildIron);
      checkVisiblityOfLinks();
      add(barracksLink);
      add(stableLink);
      add(destructionLink);
      add(upgradeLink);
      add(troopsLink);
      add(feedbackPanel);
    }
    @Override protected void onError(    AjaxRequestTarget target,    Form<?> form){
    }
  }
;
  updateBildingCounter(building,newButton);
  newForm.add(newButton);
  return newForm;
}

Fixed version (ground truth):
private Form<?> createForm(String form,final String button,final BuildingType type){
  Form<?> newForm=new Form<Object>(form);
  final Building building=buildings.get(type);
  AjaxButton newButton=new AjaxButton(button){
    private static final long serialVersionUID=-9098940045535772960L;
    @Override protected void onSubmit(    AjaxRequestTarget target,    Form<?> form){
      Building building=buildings.get(type);
      if (building != null) {
        Integer newLevel=building.getLevel() + 1;
        building.setLevel(newLevel);
        buildingsDao.beginTransaction();
        buildingsDao.update(building);
        mapUserDao.update(baseutils.reduceRessources(mapUser,500));
        buildingsDao.commitTransaction();
        updateBildingCounter(building,this);
        info("String_Node_Str");
      }
 else {
        building=new Building();
        building.setLevel(1);
        building.setType(type);
        building.setUpgrading(false);
        building.setSquare(square);
        square.getBuildings().add(building);
        buildingsDao.beginTransaction();
        buildingsDao.insert(building);
        squareDao.update(square);
        mapUserDao.update(baseutils.reduceRessources(mapUser,1500));
        buildingsDao.commitTransaction();
        updateBildingCounter(building,this);
        buildings.put(type,building);
        info("String_Node_Str");
      }
      target.add(buildWood);
      target.add(buildClay);
      target.add(buildStable);
      target.add(buildBarracks);
      target.add(buildUpgrades);
      target.add(buildDestruction);
      target.add(buildGrain);
      target.add(buildIron);
      checkVisiblityOfLinks();
      target.add(barracksLink);
      target.add(stableLink);
      target.add(destructionLink);
      target.add(upgradeLink);
      target.add(troopsLink);
    }
    @Override protected void onError(    AjaxRequestTarget target,    Form<?> form){
    }
  }
;
  updateBildingCounter(building,newButton);
  newForm.add(newButton);
  return newForm;
}