3 Replies Latest reply on Aug 28, 2008 8:36 AM by nimo stephan

    New EntityInstance via SessionBean

    nimo stephan Master

      Hello,


      I have EJB-Project.


      In the WEB-INF/classes, I have a POJO called Pojo.java.


      In my EJB, I have a SessionBean called SessionBean and an EntityBean called Entity.


      Now, I want to create a new Instance of my Entity within my Pojo. All works with Injection via @In:


      public class Pojo {


      // to retrieve the methods of my EJB-Bean
      @In
      SessionBean sessionBean;


      @In
      Entity entity;
      ...


      }


      All works, but I have doubts bout that:


      Should I create a new Instance of my Entity via the interface of my SessionBean or can I create the Instance via the Seam-Managed-Entity? What is better?


        • 1. Re: New EntityInstance via SessionBean
          nimo stephan Master

          When I reference my SessionBean via the @Local or the @Remote-Annotation, then I do not know, if the injection of my EntityBean (which is definitly not a SessionBean) works.


          Any Suggestions?

          • 2. Re: New EntityInstance via SessionBean
            Joshua Jackson Master

            What do you mean by creating new Instance? Do you mean by instantiating it with new Entity() ?
            Of course it is better that Seam provides your entity by injecting it with @In. :-)

            • 3. Re: New EntityInstance via SessionBean
              nimo stephan Master

              Yes, I mean instantiating.


              What about distributed systems and EJB. In EJB I have (one or more) Interfaces between my sessionBeans and my viewBeans. My viewBeans have access to methods of my sessionBeans via the Interface and via the @EJB-Injection. So, when I use the @In, I do not need any Interfaces ?? I do not have an Interface between my entityBean and my viewBean! However, can inject a new Instance of my entityBean in my viewBean via @In, but this is not the idea of what EJB stands for: MethodInvocation via Interfaces.


              However, I can instantiate my entityBean in my sessionBean and have indirectly instantiate it by injecting my sessionBean to my viewBean via @EJB. Is this the clean way?


              What do you think about that?