public List<Application> findByEmp(Employee emp)
{
    return (List<User>)getHibernateTemplate().find("from Application as a where" +
                                                    "a.attend.employee=?", emp);
}请问  find方法中 ? 这个 占位符  后面 那个 emp 参数 是什么意思,
还有  find方法中的 HQL 语句必须要写成 带 +  连接符 这样的 格式 吗  可不可以不写 加号 呢?

解决方案 »

  1.   

    那个emp就代表你要查询的条件啊。你先前那个占位符不就是为他占得地方么。
    hibernate  API是这样写的。
    public List find(String query,
                     Object value,
                     Type type)
              throws HibernateException Deprecated. use Session.createQuery(java.lang.String).setXYZ.Query.list() Execute a query with bind parameters, binding a value to a "?" parameter in the query string.
     
    Parameters:query - the query stringvalue - a value to be bound to a "?" placeholder (JDBC IN parameter).type - the Hibernate type of the value Returns:a distinct list of instances (or arrays of instances) Throws: HibernateExceptionSee Also:for access to Type instances
      

  2.   

    不需要+号  你那个+好是你按了回车。  eclipse自动给你拼接上去的。