title: What is the easiest way to have CDI and JPA in Java SE?
body: <p>I would like to have in Java SE</p>
  
  <pre><code>@Stateless
  public class CarDAO {
      @Inject
      private EntityManager em;
  
      public Car findById(Long id) {
          return em.find(Car.class, id);
      }
  }
  
  @Singleton
  public class Application {
      @Inject
      private CarDAO carDAO;
  
      public void run() {
          Car car = carDAO.findById(44);
          System.out.println(car);
      }
  }
  
  public class EntryPoint {
      public static void main(String[] args) {
          Application application = // missing code
          application.run();
      }
  }
  </code></pre>
  
  <p>What I have to do to achieve that? I'm using postgres database, and maven in my project.</p>
  
  <p>I was already reading something about Weld (but it looks only like CDI). I don't know how to add to Weld
  possibilty to inject Entity Manager. I know that I can obtain Entity Manager with</p>
  
  <pre><code>EntityManagerFactory emf = Persistence.createEntityManagerFactory("mgr");
  EntityManager em = emf.createEntityManager();
  </code></pre>
  
  <p>but it's not so convenient as injecting.</p>
  
  <p>It would be great if there is any tutorial about that.  Anyway, thanks for any help!</p>