select * from t_user where id in(select friendid from t_friend where userid=?)||id in (SELECT userid from t_friend where friendid=?)
还有就是,getHibernateTemplate().find(),怎样才能使用SQL?
------解决方案--------------------
HQL:
from t_user where id in(select friendid from t_friend where userid=?) or id in (SELECT userid from t_friend where friendid=?)
------解决方案--------------------
要使用sql就要用到session对象,getHibernateTemplate().executeFind(new HibernateCallback() { public Object doInHibernate(Session session) /*...*/}参数是session,在里面进行操作后返回值接收就可以了,直接用sql吧!