java - QueryDSL - Sum where a join is involed -
given following classes:
class user { @onetomany set<transaction> transactions } class transaction { bigdecimal money; }
i'm stumped how perform aggregate, functions don't appear available on following query:
quser $user = quser.user; qtransaction $transaction = qtransaction.transaction; query().from($user) .innerjoint($user.transactions, $transaction) .where($user.eq(myuser)) // what?
as bonus -- possible if money
persisted joda money type, rather bigdecimal?
(i'm using usertype's joda money support facilitate persistence)
something should work
quser $user = quser.user; qtransaction $transaction = qtransaction.transaction; query().from($user) .innerjoint($user.transactions, $transaction) .where($user.eq(myuser)) .singleresult($transaction.money.sum());
querydsl doesn't have (yet) direct support joda money, using joda money sum() method won't available directly.
Comments
Post a Comment