0
我想使用FetchProfile与我的DAO为实体示例。休眠enableFetchProfile - >未知
这是对我的实体注释:
@FetchProfiles({ @FetchProfile(name = "example-profile", fetchOverrides = {
@FetchProfile.FetchOverride(entity = Example.class, association = "association1", mode = FetchMode.JOIN),
@FetchProfile.FetchOverride(entity = Example.class, association = "association2", mode = FetchMode.JOIN) })
})
这是我的DAO:
@Autowired
private SessionFactory sessionFactory;
public Example getExample(Long id) {
sessionFactory.getCurrentSession().enableFetchProfile("example-profile");
return (Example) sessionFactory.getCurrentSession().get(Example.class, id);
}
当我打电话getExample,我得到这个异常:
org.hibernate作为.UnknownProfileException:未知获取配置文件[example-profile]
我是否缺少映射或什么?