you can use @subselect annotation
here is an example of official documentation:
@Entity @Subselect("select item.name, max(bid.amount), count(*) " + "from item " + "join bid on bid.item_id = item.id " + "group by item.name") @Synchronize( {"item", "bid"} ) //tables impacted public class Summary { @Id public String getId() { return id; } ... }
biancardi
source share