public CreatePage srCreatePage(TbInfo tbInfo,String param,int pageSize,String currentP,String gowhich)
{
CreatePage cp=new CreatePage();
Criteria c=this.getSession().createCriteria(TbInfo.class);
if(param.equals("like"))
{
System.out.println("*************************************like");
if(null != tbInfo)
{
if(tbInfo.getId()!=null)
{
System.out.println();
c.add(Restrictions.eq("id",tbInfo.getId()));
}
if(tbInfo.getInfoTitle()!=null && !tbInfo.getInfoTitle().equals(""));
{
System.out.println("########################title"+tbInfo.getInfoTitle());
c.add(Restrictions.like("infoTitle", tbInfo.getInfoTitle() , MatchMode.ANYWHERE ));
}
if(tbInfo.getInfoContent()!=null && !"".equals(tbInfo.getInfoContent()))
{
System.out.println("########################content"+tbInfo.getInfoContent());
c.add(Restrictions.like("infoContent", tbInfo.getInfoContent(), MatchMode.ANYWHERE));
}
if(tbInfo.getInfoLinkman()!=null && !"".equals(tbInfo.getInfoLinkman()))
{
c.add(Restrictions.like("infoLinkman", tbInfo.getInfoLinkman(), MatchMode.ANYWHERE));
}
if(tbInfo.getInfoPhone()!=null && !"".equals(tbInfo.getInfoPhone()))
{
c.add(Restrictions.like("infoPhone", tbInfo.getInfoPhone(), MatchMode.ANYWHERE));
}
if( tbInfo.getInfoEmail()!=null && !"".equals(tbInfo.getInfoEmail()))
{
System.out.println("########################email"+tbInfo.getInfoEmail());
c.add(Restrictions.like("infoEmail", tbInfo.getInfoEmail(), MatchMode.ANYWHERE));
}
}
}
else
{
System.out.println("*************************************all");
if(null != tbInfo)
{
if(tbInfo.getId()!=null)
{
c.add(Restrictions.eq("id",tbInfo.getId()));
}
if(tbInfo.getInfoTitle()!=null && !tbInfo.getInfoTitle().equals(""));
{
c.add(Restrictions.like("infoTitle", tbInfo.getInfoTitle() , MatchMode.EXACT ));
}
if(tbInfo.getInfoContent()!=null && !"".equals(tbInfo.getInfoContent()))
{
c.add(Restrictions.like("infoContent", tbInfo.getInfoContent(), MatchMode.EXACT));
}
if(tbInfo.getInfoLinkman()!=null && !"".equals(tbInfo.getInfoLinkman()))
{
c.add(Restrictions.like("infoLinkman", tbInfo.getInfoLinkman(), MatchMode.EXACT));
}
if(tbInfo.getInfoPhone()!=null && !"".equals(tbInfo.getInfoPhone()))
{
c.add(Restrictions.like("infoPhone", tbInfo.getInfoPhone(), MatchMode.EXACT));
}
if(tbInfo.getInfoEmail()!=null && !"".equals(tbInfo.getInfoEmail()))
{
c.add(Restrictions.like("infoEmail", tbInfo.getInfoEmail(), MatchMode.EXACT));
}
}
}
int count=((Integer)c.setProjection(Projections.rowCount()).uniqueResult()).intValue();
System.out.println("%%%%%%%%%%%%%%%%%%%%count"+count);
//String strCount=count.toString();
cp.setAllr(count);//总记录数
cp.setAllp();//总页数
cp.setCurrentP(currentP);//当前页码
cp.setPageInfo();//分页导航栏信息
cp.setPageLink(gowhich);//分页状态显示信息
return cp;
}
为什么 返回的记录是为0呢?
而且还有这样的异常
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [select this_.id as id0_0_, this_.info_type as info2_0_0_, this_.info_title as info3_0_0_, this_.info_content as info4_0_0_, this_.info_linkman as info5_0_0_, this_.info_phone as info6_0_0_, this_.info_email as info7_0_0_, this_.info_date as info8_0_0_, this_.info_state as info9_0_0_, this_.info_payfor as info10_0_0_ from db_CityInfo.dbo.tb_info this_ where this_.id=? and this_.info_title like ? order by this_.info_date asc]; SQL state [null]; error code [0]; 只进 ResultSet 不支持请求的操作。; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: 只进 ResultSet 不支持请求的操作。
{
CreatePage cp=new CreatePage();
Criteria c=this.getSession().createCriteria(TbInfo.class);
if(param.equals("like"))
{
System.out.println("*************************************like");
if(null != tbInfo)
{
if(tbInfo.getId()!=null)
{
System.out.println();
c.add(Restrictions.eq("id",tbInfo.getId()));
}
if(tbInfo.getInfoTitle()!=null && !tbInfo.getInfoTitle().equals(""));
{
System.out.println("########################title"+tbInfo.getInfoTitle());
c.add(Restrictions.like("infoTitle", tbInfo.getInfoTitle() , MatchMode.ANYWHERE ));
}
if(tbInfo.getInfoContent()!=null && !"".equals(tbInfo.getInfoContent()))
{
System.out.println("########################content"+tbInfo.getInfoContent());
c.add(Restrictions.like("infoContent", tbInfo.getInfoContent(), MatchMode.ANYWHERE));
}
if(tbInfo.getInfoLinkman()!=null && !"".equals(tbInfo.getInfoLinkman()))
{
c.add(Restrictions.like("infoLinkman", tbInfo.getInfoLinkman(), MatchMode.ANYWHERE));
}
if(tbInfo.getInfoPhone()!=null && !"".equals(tbInfo.getInfoPhone()))
{
c.add(Restrictions.like("infoPhone", tbInfo.getInfoPhone(), MatchMode.ANYWHERE));
}
if( tbInfo.getInfoEmail()!=null && !"".equals(tbInfo.getInfoEmail()))
{
System.out.println("########################email"+tbInfo.getInfoEmail());
c.add(Restrictions.like("infoEmail", tbInfo.getInfoEmail(), MatchMode.ANYWHERE));
}
}
}
else
{
System.out.println("*************************************all");
if(null != tbInfo)
{
if(tbInfo.getId()!=null)
{
c.add(Restrictions.eq("id",tbInfo.getId()));
}
if(tbInfo.getInfoTitle()!=null && !tbInfo.getInfoTitle().equals(""));
{
c.add(Restrictions.like("infoTitle", tbInfo.getInfoTitle() , MatchMode.EXACT ));
}
if(tbInfo.getInfoContent()!=null && !"".equals(tbInfo.getInfoContent()))
{
c.add(Restrictions.like("infoContent", tbInfo.getInfoContent(), MatchMode.EXACT));
}
if(tbInfo.getInfoLinkman()!=null && !"".equals(tbInfo.getInfoLinkman()))
{
c.add(Restrictions.like("infoLinkman", tbInfo.getInfoLinkman(), MatchMode.EXACT));
}
if(tbInfo.getInfoPhone()!=null && !"".equals(tbInfo.getInfoPhone()))
{
c.add(Restrictions.like("infoPhone", tbInfo.getInfoPhone(), MatchMode.EXACT));
}
if(tbInfo.getInfoEmail()!=null && !"".equals(tbInfo.getInfoEmail()))
{
c.add(Restrictions.like("infoEmail", tbInfo.getInfoEmail(), MatchMode.EXACT));
}
}
}
int count=((Integer)c.setProjection(Projections.rowCount()).uniqueResult()).intValue();
System.out.println("%%%%%%%%%%%%%%%%%%%%count"+count);
//String strCount=count.toString();
cp.setAllr(count);//总记录数
cp.setAllp();//总页数
cp.setCurrentP(currentP);//当前页码
cp.setPageInfo();//分页导航栏信息
cp.setPageLink(gowhich);//分页状态显示信息
return cp;
}
为什么 返回的记录是为0呢?
而且还有这样的异常
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [select this_.id as id0_0_, this_.info_type as info2_0_0_, this_.info_title as info3_0_0_, this_.info_content as info4_0_0_, this_.info_linkman as info5_0_0_, this_.info_phone as info6_0_0_, this_.info_email as info7_0_0_, this_.info_date as info8_0_0_, this_.info_state as info9_0_0_, this_.info_payfor as info10_0_0_ from db_CityInfo.dbo.tb_info this_ where this_.id=? and this_.info_title like ? order by this_.info_date asc]; SQL state [null]; error code [0]; 只进 ResultSet 不支持请求的操作。; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: 只进 ResultSet 不支持请求的操作。
解决方案 »
- jbpm4.4,如何使用AssignmentHandler接口
- jsp中,多个按钮的跳转问题
- 急救啊各位大大!关于SSH中dataSource和sessionFactory代码!!
- 开发Web Services工具调查
- java调用vb的dll问题,请有时间的朋友进来看看.
- 在线等!cache的问题.
- jsf的问题[有答案后马上给分]
- 有人做过图形报表吗,推荐一下
- tomcat问题
- 怎么比较?session里 util.Date 的日期 和 页面<input type="text"> 里 日期 的大小?
- [org.hibernate.util.JDBCExceptionReporter] 只进 ResultSet 不支持请求的操作。
- hibernate的缓存和延迟加载
select
count(*) as y0_
from
db_CityInfo.dbo.tb_info this_
where
this_.id=?
and this_.info_title like ?
%%%%%%%%%%%%%%%%%%%%count0
这是怎么回事呀 ?
Hibernate:
select
count(*) as y0_
from
db_CityInfo.dbo.tb_info this_
where
this_.id=?
and this_.info_title like ?
%%%%%%%%%%%%%%%%%%%%count0
从sql上可以看出title接受到值了,但是没有满足where的数据,还有id的值为空,不知道为什么sql语句中where条件中为什么还id这样的条件呢?
if(tbInfo.getId()!=null)
{
c.add(Restrictions.eq("id",tbInfo.getId()));
}
满足if条件,进了这个,所以会多个id的条件