hql语句-根据场所ID查找所有子场所

/**
     * 根据场所ID查找所有子场所
     * @return
     */
	@SuppressWarnings("unchecked")
	public List<SysSpotPlaceSite> findAllParentSysPlace(Long siteId,Integer siteDiffType){
		String hql = "select distinct t from SysSpotPlaceSite t ,SysSpotPlaceSite s where " +
				"((concat(t.siteFullParentId,',',str(t.siteId)) like case " +
				"when s.siteFullParentId is null " +
				"then concat(str(s.siteId),',%') " +
				"else concat(s.siteFullParentId,',',str(s.siteId),',%') end " +
				"or t.siteId=s.siteId ) and t.isDel = 1 ) " +
				"and "+(siteId==null?"null is":"s.siteId=")+":siteId " +
				"and s.siteDiffType = :siteDiffType "+
				" order by case when  t.siteFullParentId is null " +
				"then concat('0,',t.siteId) " +
				"else concat( '0,',t.siteFullParentId,',',t.siteId) end ,t.createTime asc";
		return this.getHibernateTemplate().findByNamedParam(hql,new String[]{"siteId","siteDiffType"},new Object[]{siteId,siteDiffType});
	}

你可能感兴趣的:(HQL)