sql - Hibernate query using criteria and projections -
i have sql query this
select destination_name, ig_id, count(formats) "number_of_formats" requests grouping destination_name, ig_id
i using hibernate , trying build query using criteria.
session.createcriteria(mytable.class) .setprojection(projection.projectionlist() .add(projections.rowcount() .add(projections.groupproperty("destinationname") .add(projections.groupproperty("igid") ) .list()
i not sure how count number of formats here. projection.rowcount() wont serve purpose. how should modify criteria?
use projections.count(propertyname) instead:
session.createcriteria(mytable.class) .setprojection(projection.projectionlist() .add(projections.groupproperty("destinationname") .add(projections.groupproperty("igid") .add(projections.count("format") ) .list()
sql oracle hibernate
No comments:
Post a Comment