2 Replies Latest reply on Mar 28, 2008 9:34 AM by malex

    TestNG: em.remove does nothing

    malex

      I currently have a stupid simple problem, I almost don't dare to ask. It is about removing a persisted entity from the DB in a TestNG routine.


      The remove-method looks very simple:



      public void removeUser(MyUser user) {
           log.fatal("removeUser");
           em.remove(user);
           log.fatal("DONE removeUser");
           user=null;
      }





      During the test I first create the instance in the DB successfully
      and subsequently remove it again. After this operation I
      search for the record and still find it.


      In order to track down the problem, I enabled TRACE logging and get of course very much logging from JBoss, Seam, Hibernate. But for above method I only get the following:


       [testng] FATAL [com.mytest.UserManagerImpl] removeUser
       [testng] DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.interpolator
       [testng] DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.interpolator
       [testng] DEBUG [org.jboss.seam.Component] done 
       [testng] FATAL [com.mytest.UserManagerImpl] DONE removeUser




      Can anyone give me some hint whats going on or where to investigate further?



      Environment:



      • Seam 2.0.1.GA

      • HSQL (configuration from seam-gen)

      • Java 1.5.0_13









        • 1. Re: TestNG: em.remove does nothing
          fernando_jmt

          Is your MyUser user managed by the persistence context?



          If not, try this:


          public void removeUser(MyUser user) {
               log.fatal("removeUser");
               em.remove(em.merge(user));
               log.fatal("DONE removeUser");
               user=null;
          }


          • 2. Re: TestNG: em.remove does nothing
            malex

            Yes, the MyUser instance should be managed by the persistence context (I just retrieve it in the statement before in the test routine).


            Your suggested additional merge does not bring any cure.
            I am still investigating further but thanks meanwhile!