| 注释,感觉是Hibernate的缺陷。 最后是Test.java import net.sf.hibernate.*; import net.sf.hibernate.cfg.*;
public class Test {
public static void main(String[] args) { try { SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session session = sf.openSession(); Transaction tx = session.beginTransaction(); for (int i = 0; i < 20; i++) { Customer customer = new Customer(); customer.setUsername("customer" + i); customer.setPassword("customer"); session.save(customer); }
tx.commit(); session.close(); } catch (HibernateException e) { e.printStackTrace(); } } }
好了,在项目中添加对Hibernate库文件的引用,编译执行,你会在数据库中找到新添加的记录。
上一页 [1] [2] [3] [4] [5] 下一页 |