Once you feel, you do not need the projection of a select statement, when you use the exits operator.
1) Select * from apple a where a.id = 1;
2) Select * from apple a where exists (select * from status s where s.id = a.status_id and s.code
='RED');
3) Select * from apple a where exists (select s.id from status s where s.id = a.status_id and s.code ='RED');
4) Select * from apple a where exists (select null from status s where s.id = a.status_id and s.code ='RED');
Really, we do not need that data to read, fetch, put to the memory, etc.
But the Hibernate does not allow you to skip:
4) subquery.select(null);
3) subquery.select(s.get(Status_.id));
2) subquery.select(s);
In fact he will force you to call the select() function. if you put there the root object, he will put to the SELECT statement the ID, primary key and run another select to get the data.
1) Select * from apple a where a.id = 1;
2) Select * from apple a where exists (select * from status s where s.id = a.status_id and s.code
='RED');
3) Select * from apple a where exists (select s.id from status s where s.id = a.status_id and s.code ='RED');
Really, we do not need that data to read, fetch, put to the memory, etc.
But the Hibernate does not allow you to skip:
2) subquery.select(s);
In fact he will force you to call the select() function. if you put there the root object, he will put to the SELECT statement the ID, primary key and run another select to get the data.

No comments:
Post a Comment