public class RegisterStory { private SysUserCDao sysUserCDao; @Test public void test() { SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); Session session=sessionFactory.openSession(); Transaction tx = session.beginTransaction(); String sql = "select * from sys_user where account='your_account'"; List list = session.createQuery(sql).list(); Iterator iterator = list.iterator(); while (iterator.hasNext()) { SysUserC sys_user = (SysUserC)iterator.next(); String user_id = sys_user.getUser_id(); System.err.println("user_id:"+user_id); } tx.commit(); session.close(); } }