4 Replies Latest reply on Jan 19, 2006 9:51 AM by dornus

    Prevent EntityManager persisting

    dornus Novice

      I have the following situation...

      public class MyClassBean implements MyClass {
       @PersistenceContext(unitName = "blah")
       EntityManager em;
       public List<MyTable> doSomething(){
       final Query q = em.createQuery(
       "from MyTable "
       List<MyTable> myList = q.getResultList();
       // Now I wish to take myList, and change fields
       // in it for display purposes only
       for (MyTable item : myList) {
       return myList;

      When I do this, it updates the field in the database ("so the field now starts with "|--"). I only want that first part for display purposes. I need to insert "|--" at this time, instead of later on in the code, so logically I thought I could alter my object temporarily without it being update in the database.

      I am at no time explicitly calling em.persist() or em.merge()

      How do I prevent this?