我有以下课程:
class User {
String username;
@CollectionOfElements
private Set<String> roles = new HashSet<String>();
[many more things here]
}
Query query = session.createQuery("select distinct u.username, u.roles from User u");
但它不起作用,它抛出以下异常:
org.hibernate.QueryException: not an entity [select distinct u.username,u.roles from com.eyeprevent.domain.users.User u]
抱怨
u.roles
不是实体。
where u.roles='arole'
也有可能,但同样,它不起作用)。