2012-04-06 1 views
0

エンティティの例として、私のDAOでFetchProfileを使いたいと思います。Hibernate enableFetchProfile - > unknow

これは私のエンティティの注釈です:

@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です:

org.hibernate:

@Autowired 
private SessionFactory sessionFactory; 

public Example getExample(Long id) { 
    sessionFactory.getCurrentSession().enableFetchProfile("example-profile"); 
    return (Example) sessionFactory.getCurrentSession().get(Example.class, id); 
} 

私はgetExampleを呼び出すと、私はこの例外を得ました.UnknownProfileException:フェッチプロファイルの不明[example-profile]

マッピングがありませんか?

答えて

0

このような@FetchProfilesのエンティティがSessionFactoryによってロードされていることを確認してください。

関連する問題