I'm using annotations (EJB 3) and I have something similar to what you want. While it is possible to do that with Entity Listeners, you will face some problems. Here is a piece of advice if you are going that way:
- Set all queries that are used (directly and indirectly) by the listeners to flush mode commit (Query.setFlushMode(FlushModeType.COMMIT)). Not doing so will most likely raise an exception.
- Watch for many-to-one relationships with optional = true. I am not being able to query these fields separately if they are null.
- Try not to initialize a second instance of the entity you are listening to (in order to get the currently persisted values), specially if that entity has lazy one-to-many relationships. You will also get an exception.
So I would recommend you to do your history in your business methods. Maybe you can generalize so it can be called for any entity, but using entity listeners does not sound like a good idea for the time being.