-
1. Re: newbie: automatically writing auditing data
mars1412 Feb 14, 2008 1:36 PM (in response to mars1412)to clarify my question:
is there smth. like hibernate.ejb.event.pre-update and hibernate.ejb.event.pre-insert? -
2. Re: newbie: automatically writing auditing data
mars1412 Feb 18, 2008 11:45 AM (in response to mars1412)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?
- why does the insert statement not show the data I've set on preInsert?