I am learning EJB3.1 and JPA2
I am doing following things for Insert and Update
INSERT
Common com = new Common();
com.setKeyData(keyData);
com.setKeyValue("0001");
em.persist(com);
UPDATE
Common com = em.find(Common.class, pk);
com.setKeyValue("0002");
The above code works but i would like to know if that's all i need to do for inserting and updating. I saw few posts where they do begin(), commit() etc (probably used in swing app). As i am new to JPA/ORM i really want to know if the above code is enough for a application with lot of data load, is there anything i am missing or should i read/learn more about inserting/updating data.
When should i use the EntityManager's close,clear and flush methods, in which scenario is it used.