Is it possible to map not the entire entity but just one of its columns with Hibernate? I have User and Role entities. Each user can have multiple roles, however I'd like to fetch only titles of the roles.
What I want:
class User {
private Set<String> roles;
}
What I don't want:
class User {
private Set<Role> roles;
}
Is it possible to achieve this somehow via ManyToMany relation, with a single query or maybe some other option? Without using DTO and copying role titles after fetching?
Thank you.
p.s. I have 3 tables: one for users, one for roles and one for connecting user to roles.