Dynamic Field Selection

@gsmet Hi, I request can help me out that how i can get any variable or array and table name inside loader because from there I can achieve similar result which Hibernate Criteria API given when we use projections for dynamic field selection.

I am trying to get help from community but no one is looking my query.

Hi, i’m also interested in this topic. I think it’s rather a JPA question but you are definitely JPA experts.
The question : is there a way to use projection like hibernate do but with JPA criteria api ?
The problem with the multiselect method is the need for a specific constructor for the projection.
Can we avoid that ? Can hibernate construct the entity by using setters instead of constructor ?

Maybe something like this should works, but it dont :

CriteriaBuilder builder = em.getCriteriaBuilder();
        CriteriaQuery<Company> query = builder.createQuery(Company.class);
        Root<Company> root = query.from(Company.class);
        Join<Company, Sector> sector = root.join(Company_.SECTOR);
        query.multiselect(root.get(Company_.NAME), sector.get(Sector_.NAME));

        List result = em.createQuery(query)
                .unwrap(Query.class)
                .setResultTransformer(Transformers.aliasToBean(Company.class))
                .getResultList();