On 06/18/2012 05:34 PM, Linda DeMichiel wrote:
> Hi Emmanuel, all,
>
> On 6/4/2012 2:58 AM, Emmanuel Bernard wrote:
>> Hey all,
>>
>> I am of the opinion that both DAOs should share the same persistence
>> context as they are both wrapped in the same Stateful SessionBean. Is
>> there any reason why we should purposely not propagate the same
>> persistence context?
>>
>> While I understand the propagation and the reasoning, I do think that
>> it "makes sense" for implementors and is sound but nevertheless miss
>> the ease if use and practical test especially for beginners.
>>
>> It would be much easier for people to understand that SFSB sharing the
>> same life cycle owner (the top SFSB in practice) share the same
>> persistence context.
>> PC propagation and inheritance is quite complex to grasp despite the
>> fact that we designed it to improve ease-of-use. I wonder if we can
>> make it easier for people.
>>
>> Sure, the "fix" is one line of code, namely add the @PC to the root
>> SFSB but the behavior is surprising and more than one beginner falls
>> into the trap of not adding it and end up using 2 PC with at best
>> performance issues and worse case, hard to understand identity breaks.
>>
>> Christian has expressed my opinion with stronger words but fairly
>> aligned with my ideas
>> http://4thline.org/articles/Stateful%20persistence%20context%20propagation%20in%20JPA.html
>>
>>
>
> OK, but this would be an incompatible change, which I don't think we
> should contemplate. Depending on further
> input from developers on this issue, we could consider whether
> addressing the use case by means of additional
> metadata would be beneficial.
>
Vendors could use an extension to switch between the two extended
persistence inheritance techniques. That could give some developers, a
concrete way to experiment with both inheritance techniques (single
level parent only or recursing up/across multiple levels).
My preference is to add the metadata for JPA 2.1, rather than vendors
using an extension.
Scott