-
1. Re: history table (before insert / trigger?)
epbernard Mar 30, 2006 11:55 AM (in response to cybernd)you have a @PrePersist and a @PreUpdate envent as per the EJB3 spec.
But I would recommend you to use DB triggers anyway if you don't care abour DB portability.
You can do that in hibernate hbm file through auxiliary database objects
http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#mapping-database-object -
2. Re: history table (before insert / trigger?)
cybernd Mar 31, 2006 3:20 AM (in response to cybernd)thx!
cybi -
3. Re: history table (before insert / trigger?)
mmarlatto Apr 3, 2006 4:50 PM (in response to cybernd)Hello.
Emmanuel, you don´t recommend Hibernate PreUpdateEventListener. Why? I've have the same scenario and choose this technique. Did I take the wrong technique? -
4. Re: history table (before insert / trigger?)
cybernd Apr 4, 2006 3:30 AM (in response to cybernd)Good question.
Personally my thought was that PreUpdateEventListener would be the cleaner way to implement the feature. The Trigger would be written in the same language as your application. Because its ejb, you already depend heavily on the ejb container, so java is already must have.
The problem might be the performance issue.
Did you recognize bottlenecks in your applications history facility? (More db roundtrips in comparison to the db internal trigger)
Another problem:
With all your logik inside your ejb layer, another application working directly with your tables would be able to bypass the history mechanism. So the db trigger would ensure that all updated entries are stored inside the history table.
So i think both possibilities got their (dis)advantages. The right technique depends on your usage or im wrong?
regards
cybernd@cybernd.at -
5. Re: history table (before insert / trigger?)
epbernard Apr 4, 2006 4:36 AM (in response to cybernd)envent listener are fine, this is not EJB3 standard, that's all.