1.
public void testHQLselect2(){
    
    String hql = "from User where firstname=?";
    Query query = session.createQuery(hql);
    query.setString(0, "xxx");
    query.list();
  }
 
生成的sql:
select user0_.firstname as firstname0_,
       user0_.lastname  as lastname0_,
       user0_.age       as age0_,
       user0_.address   as address0_,
       user0_.tel       as tel0_,
       user0_.zipcode   as zipcode0_,
       user0_.email     as email0_
  from t_user user0_
 where firstname = ?
2.
public void testHQLselect(){
    
    String hql = "from User where firstname=:firstname";
    Query query = session.createQuery(hql);
    query.setParameter( "firstname", "xxxx");
    query.list();
  }
 
生成的SQL:
同上