2 Replies Latest reply on Dec 2, 2007 9:31 AM by Pete Muir

    observing database updates

    Rob Shepherd Newbie

      I'd like to observe the changes being made to persisted entities.

      I'm currently using an EntityHome instance for entity management and have something like this.

      public String update()
       MyObj old = (MyObj)this.getEntityManager().find(MyObj.class, this.getInstance().getId());
       MyObj incoming = this.getInstance();
       System.out.println("OLD: " + old.getDescription() + ", NEW: " + incoming.getDescription() );
       return super.update();

      I've seen however, that even though the entity instance isn't persisted through to the underlying DB yet, the entitymanager is being clever and finding the instance coming in from the JSF components.

      To enable me to see the differences between the a) the data actually in the DB and b) the data currently known to the entitymanager.....

      I think I need to get hold of a new fresh entitymanager instance, one which doesn't have a cache of anything related.

      Please could somebody explain how I may get such an instance. OR, if you have any better places in mind for where I can observe this data flow.

      many thanks and kindest regards