Program: 45128
Project: 45128
Buggy source:
public static void main(String[] args) throws Exception {
  EntityManagerFactory factory=Persistence.createEntityManagerFactory("String_Node_Str");
  EntityManager em=factory.createEntityManager();
  EntityTransaction tx=em.getTransaction();
  UserDAO userDao=new UserDAO(em);
  MapDAO mapDao=new MapDAO(em);
  MessageDAO messageDao=new MessageDAO(em);
  SquareDAO squareDao=new SquareDAO(em);
  System.out.println("String_Node_Str");
  User nero=new User();
  nero.setName("String_Node_Str");
  nero.setFullname("String_Node_Str");
  nero.setAddress("String_Node_Str");
  nero.setEmail("String_Node_Str");
  nero.setPassword("String_Node_Str");
  User ariovist=new User();
  ariovist.setName("String_Node_Str");
  ariovist.setFullname("String_Node_Str");
  ariovist.setAddress("String_Node_Str");
  ariovist.setEmail("String_Node_Str");
  ariovist.setPassword("String_Node_Str");
  tx.begin();
  em.persist(nero);
  em.persist(ariovist);
  tx.commit();
  System.out.println("String_Node_Str");
  for (  User user : userDao.findAll()) {
    System.out.println(user);
  }
  System.out.println("String_Node_Str");
  for (  User user : userDao.findByEmail("String_Node_Str")) {
    System.out.println(user.getFullname() + "String_Node_Str" + user.getEmail());
  }
  System.out.println("String_Node_Str");
  Map map=new Map();
  map.setMaxNumUsers(100);
  map.setName("String_Node_Str");
  map.setXSize(10);
  map.setYSize(10);
  Integer xAxis=1;
  Integer yAxis=1;
  List<Square> squares=new ArrayList<Square>();
  for (int i=0; i < 100; i++) {
    if (xAxis > 10) {
      xAxis=1;
      yAxis++;
    }
    Square square=new Square();
    square.setCoordX(xAxis);
    square.setCoordY(yAxis);
    square.setMap(map);
    square.setIsHomeBase(false);
    squares.add(square);
    xAxis++;
  }
  map.setSquares(squares);
  tx.begin();
  em.persist(map);
  for (  Square sq : squares) {
    em.persist(sq);
  }
  tx.commit();
  System.out.println("String_Node_Str");
  Map playground=mapDao.findByName("String_Node_Str");
  List<MapUser> users=new ArrayList<MapUser>();
  List<Square> nerosquares=new ArrayList<Square>();
  Square neroStartsquare=squares.get(0);
  neroStartsquare.setIsHomeBase(true);
  nerosquares.add(neroStartsquare);
  MapUser neroMap=new MapUser();
  neroMap.setMap(playground);
  neroMap.setUser(nero);
  neroMap.setSquares(nerosquares);
  users.add(neroMap);
  List<Square> ariovistsquares=new ArrayList<Square>();
  Square ariovistStartsquare=squares.get(50);
  ariovistStartsquare.setIsHomeBase(true);
  ariovistsquares.add(ariovistStartsquare);
  MapUser ariovistMap=new MapUser();
  ariovistMap.setMap(playground);
  ariovistMap.setUser(ariovist);
  ariovistMap.setSquares(ariovistsquares);
  users.add(ariovistMap);
  playground.setUsers(users);
  tx.begin();
  em.persist(neroMap);
  em.persist(ariovistMap);
  em.merge(playground);
  em.merge(neroStartsquare);
  tx.commit();
  System.out.println("String_Node_Str");
  List<BaseBuilding> basebuilding=new ArrayList<BaseBuilding>();
  List<RessourceBuilding> ressourcebuilding=new ArrayList<RessourceBuilding>();
  BaseBuilding neroBarrack=new BaseBuilding();
  neroBarrack.setLevel(1);
  neroBarrack.setType(BaseBuildingType.BARRACKS);
  neroBarrack.setSquare(neroStartsquare);
  RessourceBuilding neroLumberjack=new RessourceBuilding();
  neroLumberjack.setLevel(1);
  neroLumberjack.setType(RessourceBuildingType.LUMBERJACK);
  neroLumberjack.setSquare(neroStartsquare);
  basebuilding.add(neroBarrack);
  ressourcebuilding.add(neroLumberjack);
  neroStartsquare.setBaseBuildings(basebuilding);
  neroStartsquare.setResourceBuildings(ressourcebuilding);
  tx.begin();
  em.persist(neroBarrack);
  em.persist(neroLumberjack);
  em.merge(neroStartsquare);
  tx.commit();
  System.out.println("String_Node_Str");
  for (  Square sq : squareDao.findByIsHomeBase(true)) {
    System.out.println("String_Node_Str" + sq.getCoordX() + sq.getCoordY());
    if (sq.getBaseBuildings() != null) {
      System.out.println(sq.getBaseBuildings().toString());
    }
    if (sq.getResourceBuildings() != null) {
    }
  }
  System.out.println("String_Node_Str");
  Set<User> recipients=new HashSet<User>();
  recipients.add(ariovist);
  Message message=new Message();
  message.setTimestamp(new Date());
  message.setSubject("String_Node_Str");
  message.setText("String_Node_Str");
  message.setFrom(nero);
  message.setTo(recipients);
  tx.begin();
  em.persist(message);
  tx.commit();
  System.out.println("String_Node_Str");
  for (  Message incoming : messageDao.findBySubject("String_Node_Str")) {
    System.out.println("String_Node_Str" + incoming.getTimestamp());
    System.out.println("String_Node_Str" + incoming.getSubject());
    System.out.println("String_Node_Str" + incoming.getText());
  }
  Helper.dropDatabase(em);
}

Fixed version (ground truth):
public static void main(String[] args) throws Exception {
  EntityManagerFactory factory=Persistence.createEntityManagerFactory("String_Node_Str");
  EntityManager em=factory.createEntityManager();
  EntityTransaction tx=em.getTransaction();
  UserDAO userDao=new UserDAO(em);
  MapDAO mapDao=new MapDAO(em);
  MessageDAO messageDao=new MessageDAO(em);
  SquareDAO squareDao=new SquareDAO(em);
  System.out.println("String_Node_Str");
  User nero=new User();
  nero.setName("String_Node_Str");
  nero.setFullname("String_Node_Str");
  nero.setAddress("String_Node_Str");
  nero.setEmail("String_Node_Str");
  nero.setPassword("String_Node_Str");
  User ariovist=new User();
  ariovist.setName("String_Node_Str");
  ariovist.setFullname("String_Node_Str");
  ariovist.setAddress("String_Node_Str");
  ariovist.setEmail("String_Node_Str");
  ariovist.setPassword("String_Node_Str");
  tx.begin();
  em.persist(nero);
  em.persist(ariovist);
  tx.commit();
  System.out.println("String_Node_Str");
  for (  User user : userDao.findAll()) {
    System.out.println(user);
  }
  System.out.println("String_Node_Str");
  for (  User user : userDao.findByEmail("String_Node_Str")) {
    System.out.println(user.getFullname() + "String_Node_Str" + user.getEmail());
  }
  System.out.println("String_Node_Str");
  Map map=new Map();
  map.setMaxNumUsers(100);
  map.setName("String_Node_Str");
  map.setXSize(10);
  map.setYSize(10);
  Integer xAxis=1;
  Integer yAxis=1;
  List<Square> squares=new ArrayList<Square>();
  for (int i=0; i < 100; i++) {
    if (xAxis > 10) {
      xAxis=1;
      yAxis++;
    }
    Square square=new Square();
    square.setCoordX(xAxis);
    square.setCoordY(yAxis);
    square.setMap(map);
    square.setIsHomeBase(false);
    squares.add(square);
    xAxis++;
  }
  map.setSquares(squares);
  tx.begin();
  em.persist(map);
  for (  Square sq : squares) {
    em.persist(sq);
  }
  tx.commit();
  System.out.println("String_Node_Str");
  Map playground=mapDao.findByName("String_Node_Str");
  List<MapUser> users=new ArrayList<MapUser>();
  List<StoredRessource> neroresources=new ArrayList<StoredRessource>();
  List<Square> nerosquares=new ArrayList<Square>();
  Square neroStartsquare=squares.get(0);
  neroStartsquare.setIsHomeBase(true);
  nerosquares.add(neroStartsquare);
  MapUser neroMap=new MapUser(playground,nero,neroresources,nerosquares);
  users.add(neroMap);
  List<StoredRessource> ariovistresources=new ArrayList<StoredRessource>();
  List<Square> ariovistsquares=new ArrayList<Square>();
  Square ariovistStartsquare=squares.get(50);
  ariovistStartsquare.setIsHomeBase(true);
  ariovistsquares.add(ariovistStartsquare);
  MapUser ariovistMap=new MapUser(playground,ariovist,ariovistresources,ariovistsquares);
  users.add(ariovistMap);
  playground.setUsers(users);
  tx.begin();
  em.persist(neroMap);
  em.persist(ariovistMap);
  em.merge(playground);
  em.merge(neroStartsquare);
  tx.commit();
  System.out.println("String_Node_Str");
  List<BaseBuilding> basebuilding=new ArrayList<BaseBuilding>();
  List<RessourceBuilding> ressourcebuilding=new ArrayList<RessourceBuilding>();
  BaseBuilding neroBarrack=new BaseBuilding(1,BaseBuildingType.BARRACKS,neroStartsquare);
  RessourceBuilding neroLumberjack=new RessourceBuilding(1,RessourceBuildingType.LUMBERJACK,neroStartsquare);
  basebuilding.add(neroBarrack);
  ressourcebuilding.add(neroLumberjack);
  neroStartsquare.setBaseBuildings(basebuilding);
  neroStartsquare.setResourceBuildings(ressourcebuilding);
  tx.begin();
  em.persist(neroBarrack);
  em.persist(neroLumberjack);
  em.merge(neroStartsquare);
  tx.commit();
  System.out.println("String_Node_Str");
  for (  Square sq : squareDao.findByIsHomeBase(true)) {
    System.out.println("String_Node_Str" + sq.getCoordX() + sq.getCoordY());
    if (sq.getBaseBuildings() != null) {
      System.out.println(sq.getBaseBuildings().toString());
    }
    if (sq.getResourceBuildings() != null) {
    }
  }
  System.out.println("String_Node_Str");
  Set<User> recipients=new HashSet<User>();
  recipients.add(ariovist);
  Message message=new Message(new Date(),"String_Node_Str","String_Node_Str",nero,recipients);
  tx.begin();
  em.persist(message);
  tx.commit();
  System.out.println("String_Node_Str");
  for (  Message incoming : messageDao.findBySubject("String_Node_Str")) {
    System.out.println("String_Node_Str" + incoming.getTimestamp());
    System.out.println("String_Node_Str" + incoming.getSubject());
    System.out.println("String_Node_Str" + incoming.getText());
  }
  Helper.dropDatabase(em);
}