With @In you inject the seam entitymanager which is injected all over the conversation. for further informations read the manual.
I just finished writing an extremely detailed explanation of the difference between the two in the updated chapters 8 and 9 of Seam in Action. These chapters will go out with the MEAP in a week or so. I can try to summarize with a few short bullets:
- Seam is not involved in @PersistenceContext injection
- It is proxied to give you EL and Hibernate Search
- Right now manual flushing and Hibernate filters are not available
- There are complex rules for sharing amongst EJB components and JavaBean components cannot use it at all
Again, I go through all of this in detail.
Dan -- I'm looking fwd for that revision as I'm disappointed with the coverage of this topic in the initial MEAP release.
Personally, I prefer using @In as Seam adds many
featureson top of EJB3, does flushing/merging all by default without the need to override these settings, in most standard use cases. Most importantly, you won't get the infamous LazyInitializationException if use @In. I have't trried the extended Persistent Context in @PersistenContext though.
Thanks, Dan. It isn't clear to me if the last 3 bullet points apply to @In or @PersistenceContext. Can you elaborate? I'll definitely be getting your book, even if I don't know what MEAP means.
You won't be disappointed with the new chapters (chapter 8 and 9). Also, I explain LIE and its circumstances in detail. You don't need @In to avoid LIE, you need a conversation-scoped persistence context. Seam's EntityManager is conversation-scoped by default. A container-managed persistence context is made conversation-scoped by using @PersistenceContext(EXTENDED) on SFSB.
All of those bullet points pertain to @PersistenceContext injection. As you can see, you can make it work, but a Seam-managed persistence context is just inherently better.
MEAP = Manning Early Access Program (basically, a PDF of the chapters in rough format)