We have an entity, for example:

@Entity public class User {...} 

and USERS table

 id, name, email, password, roleId 

in class we just started

 int id String name String email 

Is it possible to get an object like this:

 List<User> users = session.createQuery("from User where roleid=2").list()? 

those. roleId is a field in the table, but it is not in Entity. Tell me, people! Thank.

    1 answer 1

    Native Sql will help you

    • yes, but it returns Object [] and not the entity I need - Jenkamen
    • Thank you, this is what you need) - Jenkamen