Haven't used them myself but isn't there a
restrictionsconcept with entityqueries?
Yes, but it turns out that I don't want to use parameters in a WHERE clause but with a select that does dynamic instantiation.
In that case I cannot use restrictions unfortunately.
Last time I was looking, I could not find any drop-in solution, but you can subclass EntityQuery and override the required methods. It's designed for extension.
I did something similar with HibernateEntityQuery (using a hibernate session), where I had to override createQuery() to create a org.hibernate.SQLQuery and do some pre-processing (before parseEjbql()).
In this method you can set the required parameters right after the query is created. This query is a familiar JPA javax.persistence.Query and actually where dynamic context parameters are set.
Don't forget to adapt createCountQuery() appropriately.
Thanks for the tip Kariem!
could you please post a code example?
Thanks in advance!