zwwcn

Just another WordPress.com site

Monthly Archives: October 2011

@Unwrap and components

@Name("blog")
@Scope(ScopeType.STATELESS)
public class BlogService
{

   @In(create=true)                                                                      (1)
   private EntityManager entityManager;

   @Unwrap                                                                               (2)
   public Blog getBlog()
   {
      return (Blog) entityManager.createQuery("from Blog b left join fetch b.blogEntries")
            .setHint("org.hibernate.cacheable", true)
            .getSingleResult();
   }

}

The @Unwrap annotation tells Seam to provide the return value of the method—the Blog—instead of the actual BlogService component to clients. This is the Seam manager component pattern.