问题标签 [spring-data-envers]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
210 浏览

spring-data - 使用 spring-data-envers 查询嵌套对象的修订

我正在尝试使用spring-data-envers在我的 Java Spring Boot 项目中实现实体审计。所有实体都按应有的方式创建,但是在执行查询时我遇到了障碍。

parentRepository.findRevisions(id).stream().map(Parent::getEntity).collect(Collectors.toList());

在此选择期间,存储库应该也从子实体获取信息,而不是我得到unable to find <child object> with {id}.

根据我的实验 categoryId 正在 Category_Aud 表中搜索,而不是在具有所需数据的实际表中搜索。

代码片段:

我已经用 RevisionRepository 扩展了 Parent

并注释我的 SpringBootApplication 入口类: @EnableJpaRepositories(repositoryFactoryBeanClass = EnversRevisionRepositoryFactoryBean.class)

到目前为止我找不到任何解释,如何让 parentRepository 得到我需要的东西?

0 投票
1 回答
373 浏览

java - 有没有办法在spring boot中使用带有spring JDBCTemplate的Spring Data Envers记录审计数据库?

我正在创建一个使用MySQLspring 数据库的 spring web 应用程序JDBCTemplate。问题是我想记录存储在MySQL数据库中的数据的任何更改。我找不到任何带有 JDBCTemplates 的 Spring Data Envers 解决方案来记录更改。

记录数据库数据变化的最佳方法是什么?或者通过简单地在spring应用程序上编写一个文本文件?

0 投票
1 回答
81 浏览

java - RevisionRepository 返回具有不同 List 实现的实体 (PersistanceBag ->ListProxy)

返回列表为 ListProxy 的实体。

正常的 CrudRepository

返回具有相同内容的相同实体,但列表类型为 PersistentBag。

在集成测试中断言这两个对象的这种差异案例问题。

有什么解决办法吗?

0 投票
3 回答
2260 浏览

spring-boot - 在 Hibernate 环境中添加自定义修订时出错

当我添加自定义修订实体时,我开始收到错误:

我的修订:

我的修订监听器:

网络安全配置:

UserDetailsS​​erviceImpl:

用户存储库:

pom.xml:

0 投票
1 回答
68 浏览

java - Hibernate Envers - how to search non audited entity

I store to database entity LOG which is immutable (doesn't change) but other classes (entities) which it includes can change do I have to annotate this one with @Audited (I mean log)? This creates extra table of history which doesn't make any sense because LOG can not change so it is just creating duplicates. But when I don't add @Audited I can not search for it using AuditReader (AuditQuery) ... Could anyone help me here?

EXAMPLE:

The name of sensor or weather station can change and I need to be able to get the original data when the LOG was created.

EDITED: I will try to describe my problem in more details. I am getting some measurements from sensors of weather station which has some sensors. I need to store these measurements into database to be able to read them later (I am calling this "log"). The measurement value can not change. The log class (entity) has reference (relation ship) with weatherStation class which has reference to multiple sensors. Some informations about weatherStation and sensors can change during time such as firmware version etc. And I need to be able to get the whole log class from database at the time of measurement to be able to check the firmware number when the measurement was made for example.

I would like to achieve something like Log getLogFromDb(Long id) which would return the log class including weatherStation information at the time of measurement and information about sensors at the time of measurement.

I was able to get similar behavior with Hibernate Envers when I marked WeatherStation, Sensor and LOG as audited. But as you can see the LOG table doesn't change at all so it make no sense to have log history table because it just includes always the same data.

I hope my problem is clearer now.

This is how I do it right now:

0 投票
1 回答
225 浏览

java - Hibernate Envers - 删除实体时删除修订

是否有可能设置 Hibernate Envers 以便当我删除原始实体时,它的所有修订版也会被删除?只有当原始实体存在时,我才需要跟踪历史记录。

0 投票
1 回答
169 浏览

java - 从 Java 类动态创建 spring EnversRevisionRepository

如何创建EnversRevisionRepository动态给定的 Java Class 对象?

感谢这个答案https://stackoverflow.com/a/22342025/3771679可以成功地创建一个JpaRepository动态的,但我想实现相同的存储库,相当于:

0 投票
1 回答
136 浏览

java - 如何查询历史数据

我正在尝试使用 Spring Data JPA 和 MySql 来实现这个简单的想法。我有桌子:

然后我想得到结果为User+Question+Answer. 标准的 Spring Data 查询很好,answersRepository.findAll(); 我得到了结果:

但是如果问题可以改变,如何实现这个逻辑呢?例如User1回答了这个Who are you?问题,并且在这个问题被更改为Who are u?User2在第二个版本上回答之后。

我需要结果:

我尝试使用 Spring Data Envers (Hibernate Envers) 来实现这个逻辑,但我认为这不是发明审计的原因。那么我该怎么做呢?也许我需要使用事件溯源技术或其他东西?

0 投票
1 回答
36 浏览

hibernate-envers - 如何将实体历史记录写入另一台服务器?

我想将实体写入 server1,但将实体历史记录到 server2,如何配置我的数据源?有没有人特别提到?

0 投票
0 回答
453 浏览

spring-boot - Hibernate Envers:从审计表中删除修订条目

我目前正在使用 Hibernate Envers 和 Spring Data,我正在尝试在删除相应实体时删除审计表中的条目。我知道这不是 Envers 的常见用例,但我的项目需要这种行为。

但是,当我尝试删除实体和修订条目时,会在 revinfo 和 _aud 表中插入一个新的删除条目。在删除相应的修订条目后,似乎 envers 会收到实体的删除事件。有谁知道如何解决这个问题?

服务:

存储库:

日志: