为什么没有实体信息hibernate hql不能直接获取关联表(可嵌入bean)信息

为什么没有实体信息hibernate hql不能直接获取关联表(可嵌入bean)信息,hibernate,hql,Hibernate,Hql,我有一个联系,很简单: 人民友好协会 @JoinTable(name = "friendship", joinColumns = @JoinColumn(name = "people1_id")) @MapKeyManyToMany(targetEntity = People.class, joinColumns = @JoinColumn(name = "people2_id")) @Column(name = "a_value") public Map<People, Friends

我有一个联系,很简单: 人民友好协会

@JoinTable(name = "friendship", joinColumns = @JoinColumn(name = "people1_id"))

@MapKeyManyToMany(targetEntity = People.class, joinColumns = @JoinColumn(name = "people2_id"))
@Column(name = "a_value")
public Map<People, Friendship> getFriendship() {
    return friendshipInfos;
}

@embeddable
class Friendship {
 Long years ;
}
我如何使用hql直接搜索友谊信息,并且我不需要人员信息; 使用sql我知道:

select count(*) from friendship fs where  fs.year >2 ;
但是hql如何获得可嵌入bean呢? 我用

但抛出异常

exception:org.hibernate.hql.ast.QuerySyntaxException: Friendship  is not mapped 

@Table(name=“friendy”)我认为您的友谊实体中缺少映射表。@sasi是的,友谊是可映射的,它没有映射表;但是为什么我可以直接得到可嵌入的bean呢?你在与自己作对。如果你想直接查询你的友谊对象,为什么要构建你的项目来禁止它?如果您的企业需要友谊作为域对象,请将其作为域对象。
 select fs from  Friendship fs where fs.year >2;
exception:org.hibernate.hql.ast.QuerySyntaxException: Friendship  is not mapped