Configuration conf = new Configuration().configure();
SessionFactory sf = conf.buildSessionFactory();
Session session = sf.openSession();
Transaction tx = session.beginTransaction();
Customer customer = new Customer();
customer.setUsername("tomcat");
customer.setPassword("12312");
session.save(customer);
tx.commit();
session.close();
sf.close();
hibernate中的hql语句使用的是类名,不是表名
String hql = "from User u where u.id = :myid";
Query query = session.createQuery(hql);
query.setLong("myid",users[i].getId());
List<User> list = query.list();