标签:
T t;
Configuration cfg = new Configuration();
cfg.configure();
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(cfg.getProperties()).build();
SessionFactory sessionFactory = cfg.buildSessionFactory(serviceRegistry);
Session session = sessionFactory.openSession();
session.beginTransaction();
t=(T) session.get(entityClass, id);
session.getTransaction().commit();
sessionFactory.close();
标签:
原文地址:http://www.cnblogs.com/earendil/p/4345377.html