My earlier question didn't get any response, I figured that I might not make it clear enough. So I edited it.
The code snippet below is very much like from a HQL generated SQL, given the unusual "this_" and "trade2_" alias:
SELECT
....
FROM (SELECT * FROM ASSET this_
WHERE this_.TRADE_ID IS NOT NULL
AND (this_.BOOK_ID = :1)
AND this_.BUSINESS_DATE IN (:2)
AND (this_.CLASS_ID = :3)
) this_
LEFT OUTER JOIN (SELECT *
FROM TRADE trade2_
WHERE trade2_.BUSINESS_DATE IN (:2)
AND trade2_.TRDE_BOOK_ID = :1
) trade2_
ON this_.BUSINESS_DATE = trade2_.BUSINESS_DATE
We need to have a Hibernate Criteria instance to represent the above logic, but from abundance of online posts that I've read, Criteria API doesn't seem to support FROM clause followed by a subquery. I don't know if this is even doable with a combination of Hibernate/JPA's Criteria, DetachedCriteria and Subquery APIs.
However, given that the above SQL is like a machine generated code (maybe the show.sql flag turned on?), I wonder what kind of code generated it
(NOTE: there is no way to contact the original author for the code).