[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - EJB3: Update-Listener doesn't persist Objects

Rhodan76 do-not-reply at jboss.com
Tue Dec 19 11:43:30 EST 2006


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]

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3995068#3995068

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3995068



More information about the jboss-user mailing list