DistinctRootEntityResultTransformer在JPA中不起作用

时间:2015-06-11 13:33:14

标签: hibernate jpa

我希望所有城市都没有重复,但我也得到了重复的城市。有什么想法吗?

StringBuilder queryString = new StringBuilder(" select lower (trim(addressInfo.city)) from Application as app " );
        queryString.append(" left join app.firstSignatory as firstSignatory " );
        queryString.append(" left join firstSignatory.company as company " );
        queryString.append(" left join company.addressInfo as addressInfo " );
        queryString.append(" where app.discriminator = 'SERVICE' " );
        queryString.append(" order by addressInfo.city " );

        Query query = getEntityManager().createQuery(queryString.toString());

        final ResultTransformer trans = new DistinctRootEntityResultTransformer();                  

        try {

            return  trans.transformList(query.getResultList());

        } catch (RuntimeException re) {         
            throw re;
        }

0 个答案:

没有答案