日期:2014-05-19 浏览次数:20748 次
select * from t_user_attention t1 ,(select attention_user_id from t_user_attention where fans_id='250') t2 where t1.attention_user_id='226' and t1.fans_id=t2.attention_user_id
Query query = getSession().createQuery("咋写"); query.setParameter(0, 250); query.setParameter(1, 226);
String hql="select * from t_user_attention t1 ,(select attention_user_id from t_user_attention where fans_id=:fansId) t2 where t1.attention_user_id=:userId and t1.fans_id=t2.attention_user_id"; Query query = getSession().createQuery(hql); query.setParameter("fansId", 250); query.setParameter("userId ", 226);
------解决方案--------------------
Query query = this.getSession().createSQLQuery(sql).setResultTransformer(Transformers.aliasToBean(client.class)); query.setFirstResult((pageNum - 1) * pageSize); query.setMaxResults(pageSize); List retList = query.list();