Greetings, HQL wizards. I'm looking for a single HQL query to solve this problem.
I have a table called Charge. It has cols for amount, borrower, and lender. A user can be both a borrower and lender.
I want to find the balance between user1 and user2, from the perspective of user 1. For example, for the table:
Code:
borrower lender balance
---------- -------- ---------
bruce neil 10
neil bruce 5
neil bruce 2
should return the scalar '3'
given the parameters "neil" and "bruce"
because Bruce borrowed 10 from Neil, and Neil borrowed 5 and 2 from Bruce.
Does anyone have a single query silver bullet?
Further, can you do an HQL query that finds the balance with all users, given a user? (Will the single user case work with group by)?
Thanks in advance.
-Bruce Tate[/code]