public List findByDeviceIdsRasId(final String rasId, final List deviceIds)
throws DataAccessException
{
if (StringUtils.isEmpty(rasId) || CollectionUtils.isEmpty(deviceIds))
{
return null;
}
/*return getHibernateTemplate().execute(new HibernateCallback>()
{
@Override
public List<RasPo> doInHibernate(Session session) throws HibernateException,
SQLException
{
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("(");
for (String deviceId : deviceIds)
{
stringBuffer.append("'").append(deviceId).append("'").append(",");
}
String str = stringBuffer.substring(0, stringBuffer.length() - 1);
str = str + ")";
Query query= session.createQuery("from RasPo where rasId='" + rasId + "' and deviceId in " + str);
List<RasPo> list = query.list();
return list;
}
});*/
List<RasPo> list=null;
try{
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("(");
for (String deviceId : deviceIds)
{
stringBuffer.append("'").append(deviceId).append("'").append(",");
}
String str = stringBuffer.substring(0, stringBuffer.length() - 1);
str = str + ")";
list = getHibernateTemplate().find("from RasPo where rasId=? and deviceId in ?",
new String[] {rasId, str});
}
catch (DataAccessException e)
{
throw e;
}
return list;
}
使用上面的注释的可以查询出来,但是改为find()方法后就查询不出来了。我感觉着没有什么区别了。求解