(一)
Session session=HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
String strSQL="from Province as a where a.cityName like :name";
Query query = session.createQuery(strSQL);
query.setString("name", "%"+cityName+"%");
List result=query.list();
(二)
Session session=HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
List result=session.createQuery("from Province as a where a.cityName like
'%"+cityName+"%'").list();
(三)
Session session=HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
List result=session.createQuery("from Province as a where a.cityName
like :name").setParameter("pid",cityName).list();