1

我写信征求意见。我必须监视 mysql 数据库上的某些“插入”。以什么方式更方便呢?该应用程序使用 Servlet 和 MySQL。非常感谢

4

1 回答 1

2

Depends on the persistence framework you're using.

  • If it's Hibernate, you need to implement an Interceptor and hook on onSave().
  • If it's JPA, you need to use an entity method with the @PrePersist or @PostPersist annotation.
  • If it's plain vanilla JDBC, just add the code to the boilerplated DAO method.

This is unrelated to servlets. The servlet is just an API for intercepting on HTTP requests. Your data access layer should be independent and transparent from that.

于 2010-06-30T22:02:23.203 回答