示例#1
0
 public UsersDataSet getUser(long id) throws DBException {
   try {
     Session session = sessionFactory.openSession();
     UsersDao dao = new UsersDao(session);
     UsersDataSet dataSet = dao.get(id);
     session.close();
     return dataSet;
   } catch (HibernateException e) {
     throw new DBException(e);
   }
 }
示例#2
0
 public long addUser(String login, String password) throws DBException {
   try {
     Session session = sessionFactory.openSession();
     Transaction transaction = session.beginTransaction();
     UsersDao dao = new UsersDao(session);
     long id = dao.insertUser(login, password);
     transaction.commit();
     session.close();
     return id;
   } catch (HibernateException e) {
     throw new DBException(e);
   }
 }
示例#3
0
 public UsersDataSet getUserByName(String name) throws DBException {
   try {
     Session session = sessionFactory.openSession();
     UsersDao dao = new UsersDao(session);
     long id = dao.getUserId(name);
     UsersDataSet dataSet = dao.get(id);
     if (id == -2) {
       return null;
     }
     session.close();
     return dataSet;
   } catch (HibernateException e) {
     throw new DBException(e);
   }
 }