0 Replies Latest reply on Aug 12, 2005 7:31 PM by jeremyc

    @Inject converting to @PersistenceContext HOWTO?

    jeremyc

      I am new to EJB 3.0 and I went through the tutorial of the EJB 3.0 TrailBlazer and found that it uses @Inject and that has been removed from the spec. I found briefly where it says to use @PersistenceContext but I am having no luck. The class is simple in the TrailBlazer:

      public @Stateless class AuthorsBean implements Authors {
       @Inject
       private EntityManager manager;
      
       public void addArticle(Author author, String title, String body) {
       manager.persist(author);
      
       author.addArticle(title, body);
       }
      
       public Author addAuthor(String name) {
       Author author = new Author();
       author.setName(name);
      
       return author;
       }
      
       public List<Author> getAllAuthors() {
       ArrayList<Author> authors = new ArrayList<Author>();
      
       Query q = manager.createQuery("from Author");
       for (Object o : q.getResultList())
       {
       authors.add((Author) o);
       }
      
       return authors;
       }
      
      }
      


      How would I convert this to function correctly?

      Thanks,

      Jeremy