问号占位
String hql = "from table where id = ?";
Query query = session.createQuery(hql);
query.setString(0, 1L);
list = query.list();
自定义参数
String hql = "from table where id = :id";
Query query = session.createQuery(hql);
query.setString("id", 1L);
list = query.list();
参考百度知道