On 2 déc. 2011, at 22:33, Linda DeMichiel wrote:
>>
>>
>> I was thinking more about the lazy associations problem. Is there room in the JPA 2.1 specification, to make an
>> enhancement that improves what applications experience when the entity manager is invoked outside the scope of a
>> transaction? I'm thinking that the container could have a way to give a hint to the persistence provider, that lazy
>> fetching should not be used for the entity manager invocation. The advantage of this enhancement, is that applications
>> will successfully be able to access the loaded entity(s) that currently fail (due to lazy fetching being used). I think
>> that the application can also make changes to work around this (e.g. use FetchType.EAGER) but I would like the same
>> (FetchType.LAZY) entity/association to work with both container/app managed entity managers (that don't run in a JTA
>> transaction).
>>
>> Perhaps this could be a (new) standard property that the container could pass to
>> EntityManagerFactory.createEntityManager(Map) that suggests that lazy fetching should be disabled. Or something more
>> generic that covers other possible problems. e.g. some hint like "javax.persistence.auto-detach" that lets the provider
>> know that loaded entities will be detached (so the provider can avoid using lazy fetching).
>>
>
> Folks, I'd like to get more opinions on this. Should we pursue this direction?
> Should we try to address this issue via fetch groups/profiles? Other?
Yes the fetch groups/profile is the right place to address this problem.