public List <Users> getcontactList(Integer userId) throws Exception{
List <Users> list = null;
//通过联系人表 Contacts 里面的userId 查询 USers表里面的用户信息。
String hql ="select * from Users u where u.userId in (SELECT c.friendId FROM Contacts c where c.userId =:contactuserId)";
Session session = null;
try
{
session = super.getSessionFactory().openSession();
Query query = session.createQuery(hql);
query.setInteger("contactuserId",userId);
//query.setParameters();
list = query.list(); return list;
}
catch (Exception ex)
{
throw new HibernateException(ex);
}
finally
{
if (session != null)
{
session.close();
}
}
List <Users> list = null;
//通过联系人表 Contacts 里面的userId 查询 USers表里面的用户信息。
String hql ="select * from Users u where u.userId in (SELECT c.friendId FROM Contacts c where c.userId =:contactuserId)";
Session session = null;
try
{
session = super.getSessionFactory().openSession();
Query query = session.createQuery(hql);
query.setInteger("contactuserId",userId);
//query.setParameters();
list = query.list(); return list;
}
catch (Exception ex)
{
throw new HibernateException(ex);
}
finally
{
if (session != null)
{
session.close();
}
}
解决方案 »
- 利用spring中this.getHibernateTemplate().execute()进行批量删除不成功,各位帮忙解决下?
- junit测试与类测试
- 项目完不成,着急,散份
- 有哪位高人熟悉JAVA/CORBA,请指教啊!!!!!
- 安装了Tomcat后,它注册了一个名称为Apache Tomcat的服务在我的机子上,我该怎样删除掉这个服务?
- 请教各位,关于一个项目
- 用Microsoft SQL Server 2000 Driver for JDBC连接数据库的问题。
- weblogic新手问题
- 同音查询问题?
- 如何捕捉jTable中选择其中一行的事件。
- 新手提问:继承HibernateDaoSupport的DAO使用findByExample()遭遇的'user'语法错误
- 有一个恶心的错误,发现东西从家里拿到公司后就到处是错误,各位帮忙看看,解决后迅速结贴
query.setParameters();
但是我是一个子语句,我不清楚该如何用?这个设置?
Query setParameterList(String string, Collection collection, Type type) throws HibernateException;
Query setParameterList(String string, Collection collection) throws HibernateException;
Query setParameterList(String string, Object[] objectArray, Type type) throws HibernateException;
Query setParameterList(String string, Object[] objectArray) throws HibernateException;
hql="select * from SalaryBaseDataForm s where 1=1 and s.cardId in (select u.cardId form SalaryUserForm u where u.depertment='"+suf.getDepertment()+"')";