You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/asciidoc/envers.adoc
+21-19Lines changed: 21 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,21 @@
1
1
[[envers.what.is.spring.data]]
2
-
== What is Spring Data Envers
2
+
== What is Spring Data Envers?
3
3
4
-
Spring Data Envers differs from other Spring Data modules in that it is always used in combination with another Spring Data Module: Spring Data JPA.
5
-
It makes typical Envers queries available in repositories for Spring Data JPA.
4
+
Spring Data Envers makes typical Envers queries available in repositories for Spring Data JPA.
5
+
It differs from other Spring Data modules in that it is always used in combination with another Spring Data Module: Spring Data JPA.
6
6
7
7
[[envers.what]]
8
8
== What is Envers?
9
9
10
-
Envers is a https://hibernate.org/orm/envers/[Hibernate module] which adds auditing capabilities to JPA entities.
11
-
This documentation assumes you are familiar with Envers just as Spring Data Envers relies on Envers being properly configured.
10
+
Envers is a https://hibernate.org/orm/envers/[Hibernate module] that adds auditing capabilities to JPA entities.
11
+
This documentation assumes you are familiar with Envers, just as Spring Data Envers relies on Envers being properly configured.
12
12
13
13
[[envers.configuration]]
14
14
== Configuration
15
15
16
-
As a starting point for using Spring Data Envers you need a project with Spring Data JPA on the classpath and an additional `spring-data-envers` dependency.
16
+
As a starting point for using Spring Data Envers, you need a project with Spring Data JPA on the classpath and an additional `spring-data-envers` dependency:
17
17
18
+
====
18
19
[source,xml,subs="+attributes"]
19
20
----
20
21
<dependencies>
@@ -29,10 +30,11 @@ As a starting point for using Spring Data Envers you need a project with Spring
29
30
30
31
</dependencies>
31
32
----
33
+
====
32
34
33
-
This will also bring `hibernate-envers` into the project as a transient dependency.
35
+
This also brings `hibernate-envers` into the project as a transient dependency.
34
36
35
-
In order to enable Spring Data Envers and Spring Data JPA we need to configure two beans and a special `repositoryFactoryBeanClass`
37
+
To enable Spring Data Envers and Spring Data JPA, we need to configure two beans and a special `repositoryFactoryBeanClass`:
36
38
37
39
====
38
40
[source,java]
@@ -71,10 +73,10 @@ public class EnversDemoConfiguration {
71
73
}
72
74
}
73
75
----
74
-
<1> This is the only difference to a normal Spring Data JPA configuration. `EnversRevisionRepositoryFactoryBean` ensures implementations of the methods in `RevisionRepository` are available.
76
+
<1> This is the only difference from a normal Spring Data JPA configuration. `EnversRevisionRepositoryFactoryBean` ensures implementations of the methods in `RevisionRepository` are available.
75
77
====
76
78
77
-
In order to actually use Spring Data Envers make one or more repositories into {spring-data-commons-javadoc-base}/org/springframework/data/repository/history/RevisionRepository.html[`RevisionRepository`] by adding it as an extended interface.
79
+
To actually use Spring Data Envers, make one or more repositories into a {spring-data-commons-javadoc-base}/org/springframework/data/repository/history/RevisionRepository.html[`RevisionRepository`] by adding it as an extended interface:
78
80
79
81
====
80
82
[source,java]
@@ -84,12 +86,13 @@ interface PersonRepository
84
86
RevisionRepository<Person, Long, Long> // <1>
85
87
{}
86
88
----
87
-
<1> The first type parameter `Person` denotes the entity type, the second (`Long`) the type of the id property and the last one (`Long`) is the type of the revision number.
88
-
For Envers in default configuration this should be `Integer` or `Long`.
89
+
<1> The first type parameter (`Person`) denotes the entity type, the second (`Long`) denotes the type of the id property, and the last one (`Long`) is the type of the revision number.
90
+
For Envers in default configuration, the revision number parameter should be `Integer` or `Long`.
89
91
====
90
92
91
-
The entity for that repository must be an entity with Envers auditing enabled, i.e. it has an `@Audited` annotation.
93
+
The entity for that repository must be an entity with Envers auditing enabled (that is, it must have an `@Audited` annotation):
92
94
95
+
====
93
96
[source,java]
94
97
----
95
98
@Entity
@@ -102,11 +105,12 @@ class Person {
102
105
@Version Long version;
103
106
}
104
107
----
108
+
====
105
109
106
110
[[envers.usage]]
107
111
== Usage
108
112
109
-
You may now use the methods from `RevisionRepository` to query the revisions of the entity as demonstrated in the following test case.
113
+
You can now use the methods from `RevisionRepository` to query the revisions of the entity, as the following test case shows:
110
114
111
115
====
112
116
[source,java]
@@ -183,18 +187,16 @@ class EnversIntegrationTests {
183
187
}
184
188
}
185
189
----
186
-
<1> This references the application context configuration presented above.
190
+
<1> This references the application context configuration presented earlier (in the <<envers.configuration>> section).
187
191
====
188
192
189
193
[[envers.resources]]
190
194
== Further Resources
191
195
192
-
There is a https://github.com/spring-projects/spring-data-examples[Spring Data Envers example in the Spring Data Examples repository] that you can download and play around with to get a feel for how the library works.
196
+
You can download the https://github.com/spring-projects/spring-data-examples[Spring Data Envers example in the Spring Data Examples repository] and play around with to get a feel for how the library works.
193
197
194
198
You should also check out the {spring-data-commons-javadoc-base}/org/springframework/data/repository/history/RevisionRepository.html[Javadoc for `RevisionRepository`] and related classes.
195
199
196
-
Questions are best asked at https://stackoverflow.com/questions/tagged/spring-data-envers[Stackoverflow using the `spring-data-envers` tag].
200
+
You can ask questions at https://stackoverflow.com/questions/tagged/spring-data-envers[Stackoverflow by using the `spring-data-envers` tag].
197
201
198
202
The https://github.com/spring-projects/spring-data-envers[source code and issue tracker for Spring Data Envers is hosted at GitHub].
0 commit comments