??? @Entity(name="greenpages.jpa.model.Listing")
??? @Table(name="LISTING")
??? public class Listing implements Serializable{
? ? ...... ??
??? }
?
??? String queryString = "select l from Listing l where upper(l.lastName) like ?";
??? List<Listing> list = this.getHibernateTemplate().find(queryString,new Object[]{"%" +
??? term.toUpperCase() + "%"});
?
??? 说明:[email protected],上述查询语句:queryString或写成:
??? select l from greenpages.jpa.model.Listing l where upper(l.lastName) like ?,
??? 都将产生异常:
??? org.hibernate.QueryException: in expected: l [select l from Listing l where upper(l.lastName)
??? like ?],
??? 若不指定该属性,则查询语句:queryString也可写成:
??? select l from greenpages.jpa.model.Listing l where upper(l.lastName) like ?,查询均成功。
2.
?
?