java - HQL how to use sum function for list in entity -
hi need help;
how use sum function of hql list of entity onetomany.
i try explain problem via code examples.
here invoice entity
@entity public class invoice extends extendedbaseentity { @column(nullable = true,length = 50) private string invoiceno; @column(nullable = true) @jsonformat(shape = jsonformat.shape.string, pattern = "yyyy-mm-dd't'hh:mm:ss.sssxxx", timezone = "eet") private date invoicedate; @column(nullable = true,precision = 10,scale = 2) private bigdecimal amount; getters , setters.....
and here file entity.this entity hold invoice list onetomany
@entity public class file extends extendedbaseentity { @column(nullable = true, length = 50) private string name; @column(nullable = true, length = 50) private string surname; @column(nullable = true, length = 50) private string lawyercode; @column(nullable = true, length = 50) private string sellercode; @onetomany(cascade = cascadetype.remove, fetch = fetchtype.eager) @fetch(fetchmode.select) @joincolumn(name = "mbsfile_oid") private list<invoice> invoices = new arraylist<invoice>(); setters , getters ....
and here hql, want sum(invoice.amount). query didn't work through, got wrong results.
select distinct sum(invoice.amount) totalamount file left join file.invoices invoice
how can cope this? me,please?
Comments
Post a Comment