@Test public void getByNo() throws Exception { User user = userDao.getByNo("114"); Assert.assertEquals("李元芳", user.getUser_name()); }
@Override @Transactional(propagation = Propagation.REQUIRED) public User getByNo(String no) { Session session = sessionFactory.getCurrentSession(); List users = session.createQuery("from User where user_no='" + no + "'").list(); return (User)users.get(0); }
UserDaoImpl extends HibernateDaoSupport implements UserDao { @Override @Transactional(propagation = Propagation.REQUIRED) public User getByNo(String no) { Session session = sessionFactory.getCurrentSession(); List users = session.createQuery("from User where user_no='" + no + "'").list(); return (User)users.get(0); } }
UserDaoImpl extends HibernateDaoSupport implements UserDao { @Override @Transactional(propagation = Propagation.REQUIRED) public User getByNo(String no) { Session session = sessionFactory.getCurrentSession(); List users = session.createQuery("from User where user_no='" + no + "'").list(); return (User)users.get(0); }  }
UserDaoImpl extends HibernateDaoSupport implements UserDao { @Override @Transactional(propagation = Propagation.REQUIRED) public User getByNo(String no) { Session session = sessionFactory.getCurrentSession(); List users = session.createQuery("from User where user_no='" + no + "'").list(); return (User)users.get(0); }  @Override @Transactional(propagation = Propagation.REQUIRED) List<User> findAllUser(); @Override @Transactional(propagation = Propagation.REQUIRED) int saveEntity(User user); @Override @Transactional(propagation = Propagation.REQUIRED) void saveOrUpdateEntity(User user); @Override @Transactional(propagation = Propagation.REQUIRED) void updateEntity(User user); @Override @Transactional(propagation = Propagation.REQUIRED) User getByName(String name); @Override @Transactional(propagation = Propagation.REQUIRED) User getByNo(String no); @Override @Transactional(propagation = Propagation.REQUIRED) void deleteUserById(Integer id); @Override @Transactional(propagation = Propagation.REQUIRED) void deleteUserByNo(String no); @Override @Transactional(propagation = Propagation.REQUIRED) void deleteUserByEntity(User user); }
UserDaoImpl extends HibernateDaoSupport implements UserDao { @Override @Transactional(propagation = Propagation.REQUIRED) public User getByNo(String no) { Session session = sessionFactory.getCurrentSession(); List users = session.createQuery("from User where user_no='" + no + "'").list(); return (User)users.get(0); }  @Override @Transactional(propagation = Propagation.REQUIRED) List<User> findAllUser(); @Override @Transactional(propagation = Propagation.REQUIRED) int saveEntity(User user); @Override @Transactional(propagation = Propagation.REQUIRED) void saveOrUpdateEntity(User user); @Override @Transactional(propagation = Propagation.REQUIRED) void updateEntity(User user); @Override @Transactional(propagation = Propagation.REQUIRED) User getByName(String name); @Override @Transactional(propagation = Propagation.REQUIRED) User getByNo(String no); @Override @Transactional(propagation = Propagation.REQUIRED) void deleteUserById(Integer id); @Override @Transactional(propagation = Propagation.REQUIRED) void deleteUserByNo(String no); @Override @Transactional(propagation = Propagation.REQUIRED) void deleteUserByEntity(User user);  }