hibernate,先建user.java->user.hbm.xml->hibernate.cfg.xml-> Configuration config = new Configuration();
config.configure();
// 如果hibernate.cfg.xml中没有配置的某些属性,你可以通过config.setProperty(propertyName, value);来配置.
//如config.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
SessionFactory factory = config.buildSessionFactory();
Session session = factory.openSession();
Transaction tran = session.beginTransaction();
student s = new student();
s.setBirthday("111");
s.setName("222");
session.save(s);
TUser t = new TUser();
t.setId(1);
t.setBirthday("2");
t.setName("2");
session.update(t);
config.configure();
// 如果hibernate.cfg.xml中没有配置的某些属性,你可以通过config.setProperty(propertyName, value);来配置.
//如config.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
SessionFactory factory = config.buildSessionFactory();
Session session = factory.openSession();
Transaction tran = session.beginTransaction();
student s = new student();
s.setBirthday("111");
s.setName("222");
session.save(s);
TUser t = new TUser();
t.setId(1);
t.setBirthday("2");
t.setName("2");
session.update(t);