title: JPA persist not writing to database
body: <p>I'm just trying to get to know JSF and JPA but whenever I try to persist an object into the database it seems to not write away.
  Here's the code I'm using:</p>
  
  <pre><code>@Named
  @ManagedBean
  @SessionScoped
  public class BestemmingController implements Serializable{
  
  @PersistenceUnit(unitName="RealDolmenTravelShopPU")
  @PersistenceContext(unitName="RealDolmenTravelShopPU")
  
  EntityManagerFactory emf = null;
  public void submit(){
  
  
          try{
              emf = Persistence.createEntityManagerFactory("RealDolmenTravelShopPU");
  
              EntityManager em = emf.createEntityManager();
  
              //EntityTransaction et = em.getTransaction();
              //et.begin();
  
              Bestemming nieuweBestemming = new Bestemming();
  
              Land gezochtLand = em.find(Land.class, selectedLand);
  
              nieuweBestemming.setLand(gezochtLand);
              nieuweBestemming.setNaam(bestemmingNaam);
  
              em.persist(nieuweBestemming);
  
              //et.commit();
              //em.flush();
              em.close();
          }catch (Exception e){
              e.printStackTrace();
          }finally{
              emf.close();
          }
      }
  </code></pre>
  
  <p>I tried using the EntityTransaction but it just stopped my application, without any errors or anything. So I left it out, but still it didn't write away.
  So then I tried calling flush seperately, but that didn't do anything either.
  I'm really stumped as to why this isn't working. It's probably some newbie mistake, but I would love it if someone here could help me out.</p>
  
  <p>Thanks in advance!</p>