Example #1
0
  @Override
  public List<UserTestDTO> getAllUser() {
    pm = PMF.get().getPersistenceManager();
    String jdoSql = "SELECT FROM com.wupeng.blog.vo.UserDTO";
    Query query = pm.newQuery(jdoSql);
    Object result = query.execute();

    return (result == null) ? null : (List<UserTestDTO>) result;
  }
Example #2
0
  @Override
  public boolean saveUser(UserTestDTO user) {
    pm = PMF.get().getPersistenceManager();
    Transaction tx = pm.currentTransaction();
    try {
      tx.begin();
      pm.makePersistent(user);
      tx.commit();
    } catch (Exception e) {
      if (tx.isActive()) {
        tx.rollback();
        return false;
      }
    } finally {
      pm.close();
    }

    return false;
  }