我查询了API发现
beginTransaction
public Transaction beginTransaction()
                             throws HibernateExceptionBegin 
a unit of work and return the associated Transaction object. If a new underlying transaction is required, begin the transaction. Otherwise continue the new work in the context of the existing underlying transaction. The class of the returned Transaction object is determined by the property hibernate.transaction_factory. Returns:
a Transaction instance 
Throws: 
HibernateException
See Also:
Transaction他会抛出异常,但是如果我们不处理异常却不出错,为什么??
//插入
public static void insert(){

Session session=HibernateSessionFactory.getSession();

TUser user=new TUser();
user.setUserid(1007);
user.setUsername("gulei7");



Transaction tran=session.beginTransaction();//启动事务,这里本来应该try catch
session.save(user);//插入
tran.commit();//
session.close();
}