public List<User> query(User user) {
		List list=new ArrayList();
 		String hql="from User u where 1=1";
		
		if (user != null) {
			Integer type = user.getType();
			String userName = user.getUserName();
			String realName = user.getRealName();
			Agent agent = user.getAgent();
			
			if (type != -1) {
				hql += " and u.type=?";
				list.add(type);
			}
			
			if (userName != null && !userName.trim().equals("")) {
			
				hql += " and u.userName=?";
				list.add(userName);
			}
			
			
			if (realName  != null && !realName .trim().equals("")) {
				
				hql += " and u.realName =?";
				list.add(realName );
			}
			

			if (null != agent){
				if(null != agent.getId() && agent.getId().intValue()!=0) {
					hql += " and u.agent.id=?";
					list.add(agent.getId());
				}
			}
		}
		hql += " order by u.id desc";
		Object[] objs = list.toArray();
		
		List resultList = this.getHibernateTemplate().find(hql, objs);
		return resultList;
	}