HQL: How to select all entities distinct by some column?

后端 未结 7 1273
被撕碎了的回忆
被撕碎了的回忆 2020-12-14 08:20



A simple question:
In this example I need to retrieve all objects, but these objects must have distinct msgFrom fields.
When I use

List&         


        
相关标签:
7条回答
  • 2020-12-14 08:50

    You can also use Criteria and Projection together :

    Criteria criteria = session.createCriteria( MyEntity.class );
    criteria.setProjection( Projections.distinct( Projections.property( "id" ) ) );
    

    Hope it help someone.

    0 讨论(0)
提交回复
热议问题