[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Re: newbie: automatically writing auditing data

mars1412 do-not-reply at jboss.com
Mon Feb 18 11:45:35 EST 2008


ok, I just got 1 step further

I used the  <property name="hibernate.ejb.event.post-insert" ..> event listener and assigned my class, that exetended: org.hibernate.ejb.event.EJB3PostInsertEventListener as already stated above, this works, but 'post' is the wrong time

I could not find some EJB3PreInsertEventListener and also found nothing in org.hibernate.event.*. This was because code completion in JBDS really works, and only showed me classes, that I could extend from.
That was, why I didn't see, the org.hibernate.event.PreInsertEventListener INTERFACE: I'm a dump noob...

so my new class now implements the preInsert and preUpdate interfaces and I am quite happy, but it still does not work, as expected when inserting a new record:
1) the preInsert event is called: I set the history on my entity
2) hibernate makes an insert statement, but the parameters for the created part of the history are empty (although they have been set in my eventlistner: checked in the debugger)
3) then the preUpdate event is called: my preUpdate event will also set the update part of the history (create is already set)
4) now hibernate makes an update statement of the new entity and updates both parts of the history - so after inserting the entity, created and updated are set, which is of course not what I want

any ideas why this happens?
* why does the insert statement not show the data I've set on preInsert?
  | * why is another update statement generated?

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

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



More information about the jboss-user mailing list