Beispiel #1
0
 public void create(UserBean user) throws DAOException {
   String origID = user.getUserID();
   try {
     Transaction.begin();
     user.setUserID(user.getUserID().toLowerCase());
     UserBean dBUser = factory.create(user.getUserID());
     factory.copyInto(user, dBUser);
     Transaction.commit();
   } catch (DuplicateKeyException e) {
     throw new DAOException("UserID: " + user.getUserID() + "already exists.");
   } catch (RollbackException e) {
     throw new DAOException(e);
   } finally {
     if (Transaction.isActive()) Transaction.rollback();
   }
 }
Beispiel #2
0
  public void setEvent(int eventid, String userid) throws DAOException {
    try {
      Transaction.begin();
      UserBean dbUser = factory.lookup(userid);

      if (dbUser == null) {
        throw new DAOException("User " + userid + " no longer exists");
      }

      dbUser.seteventAttendingID(eventid);
      Transaction.commit();
    } catch (RollbackException e) {
      throw new DAOException(e);
    } finally {
      if (Transaction.isActive()) Transaction.rollback();
    }
  }