hql 语句去除重复的值

傅小司 2013-10-09 12:57:16
List<TContentType> listall=new ArrayList<TContentType>();
listall=service.query("select distinct typeName,typeId from TContentType");

我该怎么获取到listall里面的typeName 属性的值,不会写了,求指点
...全文
327 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
尘缘udbwcso 2013-10-09
  • 打赏
  • 举报
回复

oracle的
怎么样抽取重复记录 
select * from table t1 where where t1.rowed != 
(select max(rowed) from table t2 
where t1.id=t2.id and t1.name=t2.name) 
或者 
select count(*), t.col_a,t.col_b from table t 
group by col_a,col_b 
having count(*)>1 

tony4geek 2013-10-09
  • 打赏
  • 举报
回复
你是要去重还是取数据。上面都说了。query 你返回的是list 吗? sql 还是hql
anliupeng 2013-10-09
  • 打赏
  • 举报
回复
循环listall可以得到TContentType对象,tContentType.getTypeName(),就取得了!
jiafeng_lee 2013-10-09
  • 打赏
  • 举报
回复
这个是要循环list取值的 网上也有更好的,可以自己去找找
public static List<ReportParamter> getBrandData(List list,String startsName) throws Exception {
		List<ReportParamter> reportParamters =  new ArrayList<ReportParamter>();
		if(!StringUtil.isEmpty(startsName)){
			for(Object obj : list){
				if(obj instanceof ReportParamter){
					ReportParamter rp = (ReportParamter)obj;
					if(!StringUtil.isEmpty(rp.getParamId()) && rp.getParamId().indexOf(startsName)!=-1){
						reportParamters.add(rp);
					}
				}
			}
		}
		return reportParamters;
	}

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧