1: OID is param
2: OID is param
3: OID is param
4: DetachedCriteria 的使用
String strSQL="from Classes as a where a.classno like :name";
Query query = session.createQuery(strSQL);
query.setString("name", "%"+OId+"%");
List result=query.list();
2: OID is param
List result=session.createQuery("from Classes as a where a.classno like '%"+OId+"%'").list();
3: OID is param
List result=session.createQuery("from Classes as a where a.classno like :name").setParameter("name",OId).list();
4: DetachedCriteria 的使用
public FunctionEntity getFunctionEntityById(String id){
DetachedCriteria criteria = DetachedCriteria.forClass(FunctionEntity.class);
criteria.add(Restrictions.eq("id", id));
return (FunctionEntity) getHibernateTemplate().findByCriteria(criteria).get(0);
}