Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.0.3
Code between sessionFactory.openSession() and session.close():
InventoryTransStockViewInfo info = (InventoryTransStockViewInfo)itsvInfo;
Criteria crt = super.getCriteria(new InventoryTransStockViewInfo());
crt.setProjection(Projections.projectionList()
.add(Projections.sum("actualquantity"))
.add(Projections.groupProperty("itemCode"))
.add(Projections.groupProperty("fieldone"))
.add(Projections.groupProperty("fieldtwo"))
.add(Projections.groupProperty("fieldthree"))
.add(Projections.groupProperty("fieldfour")));
list = (List)super.findByCriteria(crt);
Name and version of the database you are using:
PostgreSQL
The generated SQL (show_sql=true):
Hibernate: select sum(this_.actual_quantity) as y0_, this_.item_code as y1_, thi
s_.field_1 as y2_, this_.field_2 as y3_, this_.field_3 as y4_, this_.field_4 as
y5_ from inventory_transaction_stock_view this_ group by this_.item_code, this_.
field_1, this_.field_2, this_.field_3, this_.field_4
Hi
I want to add sql case in the above query(i.e in the
SUM) how do i do it using Criteria?
"sum(case when ... then ... when ... then ... else ... end)";