4 Replies Latest reply on Sep 19, 2008 7:38 AM by newlukai

    Entity Bean: @Name needed?

      Hi,


      maybe this is a more or less dumb question: Is it necessary to annotate entity beans with @Name?
      @Name tells Seam to instantiate an object of this entity whenever it is referenced. But as I'm thinking about I'm pretty sure that I don't access a plain entity on my pages. Whether there is a h:dataTable which iterates over entity beans or - especially with user - a special component is set up by another bean and so on.


      So I wonder if it's just fine to remove the @Name respectively is there any special reason why an entity should be annotated with @Name?


      Thanks
      Jens

        • 1. Re: Entity Bean: @Name needed?
          nimo22

          You do not need the @Name-Annotation in a EntityBean,
          when you do your business stuff in a session bean!


          In common, it is better to seperate Model from Controller!


          So do your business relevant things only in session beans and use the @Name-Annotation in SessionBeans.


          • 2. Re: Entity Bean: @Name needed?

            And there is really no specific reason why every entity in the docs and examples got @Names?

            • 3. Re: Entity Bean: @Name needed?
              gjeudy

              Perhaps because CRUD operations in the examples refer to the entity to create by name? If you don't want to bind directly an entity implementation to a view you can use:


              @Factory("entityName")

              and outject an interface or an abstract class (hiding actual implementation to the view), this is the Seam-ish implementation of the Factory pattern.

              • 4. Re: Entity Bean: @Name needed?

                I knew it was a more or less stupid question. But thanks, I got it again.