简体   繁体   中英

Audit using Spring hibernate mongodb

I am looking for a design approach. What i want to achieve to get all the 'old to new' changes when a entity is updated,during which also the changes to be recorded/audited into another entity. trick is former update to entiry happens in mysql using hibernate and the later entity lives in Mongo which is using morphia. both these provider inside my spring mvc, independently yet together. they dont bother each other coz all the CRUD happens independently for their respective changes. Last time, i tried a join with mongo and mysql using hibernate but realized that is not possible ! (not sure there is a solution ), But now I have take my audit changes to Mongo and track them there for every change in JPA/hibernate managed entities.

  1. I don't need a regular audit with version etc., or a additional table. for each entity.
  2. Every change in any entity needs to be trailed to only one entity in mongo. the mongo entity/document will generic Audit log.
  3. Envers not suitable
  4. hibernate interceptor, fine but how i talk to mongo, do i need ogm
  5. hibernate listeners ?
  6. spring aop
  7. spring aop + ? + ?
  8. will spring data can help ?

I have read and come up with some idea, i needs some experts to help me refine or suggest a better solution.

I am planning to implement spring aop and to intercept at service level, having a Audit service to set my Audit bean in order not to loose changes then in use some mechanism to get and set or flush the Audit change to the dedicated document in Mongo.

Not sure the above approach is meaningful and achievable. Any help will be greatly appreciated.

Audit4j支持Spring AOP支持的各种选项,但你必须为audit4j编写一个自己的MongoDB插件,目前它不可用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM