日期:2014-05-17 浏览次数:20705 次
public PagerModel findAllPropagandize(final int offset,final int pageSize,final Propagandize propagandize) throws DataAccessException { //查询总的条目数 int total = 0; if(propagandize == null){ total = Integer.parseInt(this.hibernateTemplate.find("select count(*) from Propagandize").get(0).toString()); }else if(propagandize.getPropagandizestuff() != null){ total = Integer.parseInt(this.hibernateTemplate.find("select count(*) from Propagandize p where p.propagandizestuff.stuffId="+propagandize.getPropagandizestuff().getStuffId()).get(0).toString()); }else if(propagandize.getPropagandizeSize() != null){ total = Integer.parseInt(this.hibernateTemplate.find("select count(*) from Propagandize p where p.propagandizeSize.propagandizeSizeId="+propagandize.getPropagandizeSize().getPropagandizeSizeId()).get(0).toString()); }else if(propagandize.getPropagandizeNum() != null){ total = Integer.parseInt(this.hibernateTemplate.find("select count(*) from Propagandize p where p.propagandizeNum.propagandizeNumId="+propagandize.getPropagandizeNum().getPropagandizeNumId()).get(0).toString()); }else{ total = Integer.parseInt(this.hibernateTemplate.find("select count(*) from Propagandize").get(0).toString()); } List<Propagandize> propagandizeList = this.getHibernateTemplate().executeFind(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query query = null; if(propagandize == null){ System.out.println("one"); query = session.createQuery("from Propagandize order by propagandizeId"); query.setFirstResult(offset); query.setMaxResults(pageSize); }else if(propagandize.getPropagandizestuff() != null){ System.out.println("stuff"); query = session.createQuery("from Propagandize p where p.propagandizestuff.stuffId="+propagandize.getPropagandizestuff().getStuffId()+"order by p.propagandizeId"); query.setFirstResult(offset); query.setMaxResults(pageSize); }else if(propagandize.getPropagandizeSize() != null){ System.out.println("size"); query = session.createQuery("from Propagandize p where p.propagandizeSize.propagandizeSizeId="+propagandize.getPropagandizeSize().getPropagandizeSizeId()+"order by p.propagandizeId"); query.setFirstResult(offset); query.setMaxResults(pageSize); }else if(propagandize.getPropagandizeNum() != null){ System.out.println("num"); query = session.createQuery("from Propagandize p where p.propagandizeNum.propagandizeNumId="+propagandize.getPropagandizeNum().getPropagandizeNumId()+"order by p.propagandizeId"); query.setFirstResult(offset); query.setMaxResults(pageSize); }else{ System.out.println("three"); query = session.createQuery("from Propagandize p where p.propagandizestuff.stuffId="+propagandize.getPropagandizestuff().getStuffId()+"order by p.propagandizeId"); query.setFirstResult(offset); query.setMax