Skip to content

Conversation

@schauder
Copy link
Contributor

@mp911de
Copy link
Member

mp911de commented Feb 18, 2021

Paging @Buzzardo

== Getting Started

As a starting point for using Spring Data Envers you need a project with Spring Data JPA.
The easiest way to create that is using the Spring Initializr either on start.spring.io or via its integration in your favorite IDE.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Link to start.spring.io


</dependencies>
----
This will also bring hibernate-envers into the project as a transient dependency.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Code fences for hibernate-envers

----
public interface PersonRepository
extends CrudRepository<Person, Long>,
RevisionRepository<Person, Long, Long> {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to add callouts and explain Person, Long, Long. It's not obvious why there's Long, Long.

public class EnversDemoConfiguration {}
----

The entity for that repository should be an entity with Envers auditing enabled, i.e. it has an `@Audited` annotation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should or is this a hard requirement?

[source,java]
----
@ExtendWith(SpringExtension.class)
@SpringBootTest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rewrite the test to not require Spring Boot?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't that mean we have to reference an application context configuration which then should also be included in the example? Or are you aiming for something else?


Revisions<Long, Person> revisions = repository.findRevisions(updated.id);

assertThat(revisions) //
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The // are rather distracting. Also, let's rewrite the test to a more simple form. extracting(…) and tuple aren't quite what we should expect from our audience as pre-requisite.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fully agree on the //
But I consider AssertJ the de facto standard of assertions and extracting + tuple essential and easy to understand features. Rewriting this would make it harder to understand AND enforces bad practices. I'm somewhat reluctant to do that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My motivation is that our example should be focusing on our bits/Envers bits as much as possible. The tests should just decorate the example and require as little knowledge as possible as the cognitive load to understand how to use Revisions is quite high for someone that wants to learn the topic. We should reduce the impact of our decoration on the learning steps.

john.setName("John");

//create
Person saved = tx.execute(__ -> repository.save(john));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's replace __ with transactionStatus for a more expressive example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again I don't find that more expressive but unnecessary verbose.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it's more verbose it avoids confusion with Kotlin or Scala-like implicit lambda parameters and it's not implying that any potentially newer and lesser-known feature is used. That being said, trying to remove obstacles.

mp911de pushed a commit that referenced this pull request Feb 25, 2021
mp911de added a commit that referenced this pull request Feb 25, 2021
Reformat code. Add link to Envers. Consistently use template variables.

See #61
Original pull request: #279.
mp911de pushed a commit that referenced this pull request Feb 25, 2021
mp911de added a commit that referenced this pull request Feb 25, 2021
Reformat code. Add link to Envers. Consistently use template variables.

See #61
Original pull request: #279.
mp911de pushed a commit that referenced this pull request Feb 25, 2021
mp911de added a commit that referenced this pull request Feb 25, 2021
Reformat code. Add link to Envers. Consistently use template variables.

See #61
Original pull request: #279.
@mp911de
Copy link
Member

mp911de commented Feb 25, 2021

That's merged, polished, and backported now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spring Data Envers Documentation Only Contains General Spring Data Information

3 participants