I have a class Trade and a subclass Operation. They are mapped in the database. So when I do:
trades = session.createQuery("from Trade").list()
I get an arraylist of trade records and can access the operations for certain trade through my trade instance.
However, when I do:
trades = session.createQuery("
from Trade as trade
inner join trade.operations as operation
with to_char(operation.datetime, 'yyyyMMdd') = to_char(sysdate, 'yyyyMMdd')
order by operation.datetime"
).list();
I get an array of objects where each element contains operation and trade instance.
How could I retrieve records as an array of trades (same as first option) with conditions (same as second option)?
I tried: select trade from Trade as trade inner join trade.operations as operation with to_char(operation.datetime, 'yyyyMMdd') = to_char(sysdate, 'yyyyMMdd') order by operation.datetime
It worked, thanks javatestcase. However, when I loop the trade.operations, I get trades which contain any operations by today, but I also get all the operations for that trade, even if it's the operation is from another day. So it doesn't satisfy the condition.
Any clue?
Thanks in advance!!