Annotated getter with OneToMany(fetch=FetchType.LAZY) does not lazily fetch.
delocalizer opened this issue · 2 comments
In our current project we auto-generate interfaces from an OWL ontology and use Empire's on-the-fly implementation capabilities. This works great, except that the fetch attribute value FetchType.LAZY in OneToMany, OneToOne etc. annotations we add to interface getters does not actually result in lazy instantiation of bean properties. The problem appears to be that in RdfGenerator#getProxyOrDbObject, the method supplied to BeanReflectUtil.isFetchTypeLazy method is the setter, which is not annotated with anything, and so the property is fetched eagerly. As a working kludge we also annotate the setter with @onetomany(fetch=FetchType.LAZY) etc. but I don't believe that's optimal and not something I have seen done in other JPA context. Is this a real issue, or am I missing something? If it is an issue, I have a patch here delocalizer@11367fe I can put in a PR for.
cheers,
Conrad
Yeah, that sounds like a bug. I see that it's only checking the accessor rather than the property for the annotation.
I'd be happy to take the PR to fix the issue.
I'm hoping these things are more straightforward to implement once I can move over most of the internals of the RDF<->Java to Pinto (#99)