0 Replies Latest reply on Aug 29, 2011 2:17 PM by tvlerber

    We recommend against treating entities as CDI beans...

    tvlerber

      In the Weld Reference Documentation I read ...we don't recommend directly injecting an entity class. (link)


      But then you end up with stuff in the back end like


      public void addItem() {
        entityManager.persist(newItem);
      }



      where newItem is created with 'new' . (possibly made available for EL via @Produces)


      But doesn't that make your back end code dependent of the front end? It feels wrong to me. I would much prefere a more natural method like


      public void addItem(Item item) {
        entityManager.persist(item)
      }



      whitch would be possible if I could annotate entities with @Model and then inject them when needed.


      Am I wrong about this?