select
testentity0_.id as id1_1_0_,
subs3_.id as id1_0_1_,
testentity1_.id as id1_1_2_,
subs2_.id as id1_0_3_,
testentity0_.name as name2_1_0_,
testentity0_.ref_id as ref_id3_1_0_,
subs3_.test_id as test_id2_0_1_,
testentity1_.name as name2_1_2_,
testentity1_.ref_id as ref_id3_1_2_,
subs2_.test_id as test_id2_0_3_
from
test_table testentity0_
left outer join
sub_test_table subs3_
on testentity0_.id=subs3_.test_id
inner join
test_table testentity1_
on (
testentity0_.ref_id=testentity1_.id
)