2 Replies Latest reply on Oct 9, 2008 10:44 AM by Anders Norgaard

    Where (which layer) to put Entity query methods, “persist” methods etc. ?

    Anders Norgaard Newbie

      Sorry, if this is slightly off topic. I am trying to get the most of my SEAM experience, but I am getting annoyed with my own inability to architect properly. So I wonder...



      I have a SEAM app running on JBoss 4.2 with some JPA/Hibernate entities. And I now wonder where to put my query, persistence methods.


      The default choice seems to put them in a session bean layer with injected


      @PersistenceContext(...) @Inject EntityManager entityManager;


      But I think I would rather have the methods on the entities themselves (like .persist() etc) maybe some static? What are the pro's/con's wrt.


         1. Testablity?
         2. Niceness?
         3. Performance?


      And does anyone have links to best practices for interacting with the EntityManager etc. from methods on the Entities rather than session beans?


      Best, Anders


      PS Why I don't just do the DAO-kind-of-layer: In general, I think, EJB is insanely verbose and boilerplate'y, but SEAM actually helps a bit, so that is why, in my current project, the extra layer of session beans just to query and persist annoys me. I have the feeling that I could make a reasonably concise app if I could kill this layer...