hibernate中save执行后添加成功 但是数据库中没有数据库 id增长了.
private Session session = this.getSession();private Session getSession() {
return HibernateInfo.openSession();
}
private void closeSession(){
HibernateInfo.closSession();
}
public int Add(User info) {
Transaction tx = getSession().beginTransaction();
try{
session.save(info);
tx.commit();
return 1;
}catch(RuntimeException re){
System.out.println(re);
tx.rollback();
return -1;
}finally{
session.close();
}
}
- - - - - - - - - - 测试的。
User user = new User();
user.setEuUserName("林");
user.setEuPassword("d");
BaseDAO bs = new BaseDAO();
System.out.println(bs.Add(user));
- - - - - - - - - - 控制台
Hibernate: insert into YiMai.dbo.easybuy_user (eu_user_name, eu_password, eu_易做图, eu_birthday, eu_identity_code, eu_email, eu_mobile, eu_address, eu_status) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
1
--------------------编程问答-------------------- 没有人知道么?
补充:Java , Java EE