0 Replies Latest reply on Dec 19, 2006 11:43 AM by Perry Rhodan

    EJB3: Update-Listener doesn't persist Objects

    Perry Rhodan Newbie

      Hello,

      if i try to persist a newly created object inside an hibernate3-listener, this object get never persisted in the database. Using following code-snippet for persisting:

      private void saveNewObjectFromWithinEventListener( Object myObject ) {
       try {
       InitialContext ctx = new InitialContext();
       SessionFactory factory = (SessionFactory) ctx.lookup("java:/hibernate/SessionFactory");
       factory.getCurrentSession().save(myObject);
       } catch (NamingException e) {
       throw new HibernateException(e);
       }


      Especially i using an post-update-listener of Hibernate3 inside jboss 4.0.5. The listener is registered in the persistence.xml and if i debug, i see that the listener is invoked. All runs fine, i'm getting no exception, but only the transient object will not be persisted to the database.

      Is it impossible to persist a new (transient) object created inside an hibernate-listener to the database within these listener ?

      [Using jboss 4.0.5 EJB3 RC9]