3 Replies Latest reply on Jun 1, 2010 6:54 AM by make easy

    PostDeleteEventListener call

    Aejaz Muslim Newbie


      The class looks like this:

      public class MyClass implements PostDeleteEventListener,
      PostInsertEventListener, PostUpdateEventListener, Initializable {


      public void onPostDelete(PostDeleteEvent event) {
      System.out.println("Post delete event");
      }

      public void onPostInsert(final PostInsertEvent event) {
      System.out.println("Post insert event");
      }

      public void onPostUpdate(final PostUpdateEvent event) {
      System.out.println("Post update event");
      }

      public void initialize(final Configuration config) {
      }

      }


      persistence.xml values:







      Problem is that System.out messages are coming on inserting a row in db and updating a row in db. But on a row deletion System.out message is not coming.

      jboss-5.0.0.GA is used.

        • 1. Re: PostDeleteEventListener call
          Aejaz Muslim Newbie


          The class looks like this:

          public class MyClass implements PostDeleteEventListener,
          PostInsertEventListener, PostUpdateEventListener, Initializable {


          public void onPostDelete(PostDeleteEvent event) {
          System.out.println("Post delete event");
          }

          public void onPostInsert(final PostInsertEvent event) {
          System.out.println("Post insert event");
          }

          public void onPostUpdate(final PostUpdateEvent event) {
          System.out.println("Post update event");
          }

          public void initialize(final Configuration config) {
          }

          }


          persistence.xml values:







          Problem is that System.out messages are coming on inserting a row in db and updating a row in db. But on a row deletion System.out message is not coming.

          jboss-5.0.0.GA is used.

          • 2. Re: PostDeleteEventListener call
            Aejaz Muslim Newbie


            The class looks like this:

            public class MyClass implements PostDeleteEventListener,
            PostInsertEventListener, PostUpdateEventListener, Initializable {


            public void onPostDelete(PostDeleteEvent event) {
            System.out.println("Post delete event");
            }

            public void onPostInsert(final PostInsertEvent event) {
            System.out.println("Post insert event");
            }

            public void onPostUpdate(final PostUpdateEvent event) {
            System.out.println("Post update event");
            }

            public void initialize(final Configuration config) {
            }

            }


            persistence.xml values:

            property
            name="hibernate.ejb.event.post-insert"
            value="org.hibernate.ejb.event.EJB3PostInsertEventListener, com.dgrid.htflex.services.util.MyClass"
            property
            name="hibernate.ejb.event.post-update"
            value="org.hibernate.ejb.event.EJB3PostUpdateEventListener, com.dgrid.htflex.services.util.MyClass"
            property
            name="hibernate.ejb.event.post-delete"
            value="org.hibernate.ejb.event.EJB3PostDeleteEventListener, com.dgrid.htflex.services.util.MyClass"



            Problem is that System.out messages are coming on inserting a row in db and updating a row in db. But on a row deletion System.out message is not coming.

            jboss-5.0.0.GA is used.

            • 3. Re: PostDeleteEventListener call
              make easy Newbie

              These three tags has to be placed in your hibernate.cfg.xml configuration file.

               

              <listener class=" yourpackage.MyClass" type="post-insert"/>

              <listener   class=" yourpackage.MyClass" type="post-update"/>

              <listener  class=" yourpackage.MyClass" type="post-delete"/>

               

              Thanks,

              DSK