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]
我是否缺少映射或什麼?