Dynamic Field Selection

Also my point is in each and every example out there including Hibernate JPA based Criteria Reference also says same that If my Entity have A, B, C, D, E, F fields (mapping to table is understood)
then if I need in one of my service only field A & B then i have to write

public List<Object> getFewColumns(MySearchCriteria sc) {
Path<String> A= root.get( MyEntity_.A );
Path<String> B = root.get( MyEntity_.B);

criteria.multiselect( A, B );
criteria.where( builder conditions );

List<Object[]> aAndBList= entityManager.createQuery( criteria ).getResultList();
return aAndBList;
}
// for better understanding 
/*MySearchCriteria  is a class extending our Entity AKA Bean AKA POJO, which have additional fields like */

private String[] includeMask; /* columns which needs to be selected only those fields name must be set as array */

private String[] excludeMask;/* If i have 70 columns out of that I want to select 65 then I can set rest 5 excluding columns and ORM should exclude only those columns */

private String[] valueAIn; /* for where clause in which I can set a specific to A fiels value upto 1000 entries to use dynamically create in criteria */

private String[] orderBy[]; /* for dynamically setting columns in which i want ordering
its and Search criteria class which can help me to build where clause and select clause dynamically and pass it to my DAO which will prepare SQL/JPQL/HQL according to this clause field values,it helps to keep intact Entity as well helps to prepare dynamic query without creating boiler plate methods */

now if I want to get A,B & F columns only from same method getFewColumns I can’t i have to amend it or need to write another method for specifically selection of A, B & F

this leads boiler plate code also if I want to use NamedQueries that will not help me since that also leads to boiler plate code.

One more drawback I am not getting object of my Entity, instedof that I am getting Object Array List which I need to further cast back to my Entity object, as have to initialize entity and set each selected fields eg

List<MyEntity> entityList = new ArrayList(aAndBList.size);
for(Object[] obj: aAndBList){

MyEntity entity = new MyEntity ();
entity .setA(obj[0]);
entity .setB(obj[0]);

entityList .add(entity);
}

Above code is absolutely unnecessary if orm can’t give me this task done automatically.

hope you got my point, if you need I can share my old framework working which has this capability and guide me how can I achieve same in JPA criteria Query of Hibernate,

we r moving out of old ORM because its proprietary to us only, no proper documentation & reference and there is no scalability along with features like cashing & transaction management