Question

So for example, if I create a JPQLQuery for the User entity like this:

public class QUser extends EntityPathBase<User> {}

QUser qUser = QUser.User;
JPQLQuery query = new HibernateQuery(getSession()).from(qUser);

Is it possible to do the same if I only have the persistent class?

JPQLQuery query = createFromPersistentClass(User.class);

Thanks in advance for any help.

Was it helpful?

Solution

You can replace

QUser qUser = QUser.user;

with

PathBuilder<User> qUser = new PathBuilder<>(User.class, "user");

or in a generic way

PathBuilder<?> qEntity = new Pathbuilder(clazz, "entity");

Replace "entity" with any variable name you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top