We are using dynamic HQL query generator which generates query like below query:
select sum(en1.amount) from SampleEntity1 as en1 where en1.child.name = ? Hibernate will convert above query to sql as follows:
select sum(tbl1.c_amount) from sampletable1 as tbl1, samplechild as child1 where tbl1.c_child = child1.c_id and child1.c_name = ? Tables sampletable1 and samplechild both have more than 1 million records and because the generated sql has cross join, the performance of the query is very low and it suffers lots of database I/O. But if we run the sql using inner join the query will be run in much better performance.
Is there any way to force hibernate to convert such HQL queries to inner join instead of cross join?