Session session;
session=HibernateSessionFactory.getSession();
Transaction tran=null;
try{
tran=session.beginTransaction();
//insert
/* user.setName("aabbcc");
TUser user=new TUser();
session.save(user);
session.flush();*/
//delete
/* String hql="delete TUser where name='abc'";
Query query=session.createQuery(hql);
query.executeUpdate();*/
//find hibernate3取消了find方法,可以用以下方法
String hql="from TUser user where user.name like 'a%'";
Query query=session.createQuery(hql);
List list=query.list();
Iterator it=list.iterator();
while(it.hasNext()){
TUser user=(TUser)it.next();
System.out.println(user.getName());
}
tran.commit();
}catch(HibernateException e){
}
HibernateSessionFactory.closeSession();